sudden memory leaks with Random



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/10/2009 at 12:44, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   r11 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    today i compiled an older plugin on my vista pc and what happened? i got memory leaks which are not there on the other computer...

    the cmd is pointing to the lines where i use:

    Random *rnd = gNew Random;

    any ideas whats this thing about??

    and why does this happen on one pc but not the other??

    thanks in advance,
    ello



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/10/2009 at 16:04, xxxxxxxx wrote:

    just for clarification: I have this snippet as a helper function:
    _
    Real zufall (Real scale, int seed)
         {
          Random* rnd = gNew Random;
         rnd->Init(seed);
         return rnd->GetG11()*scale;
         }
    _

    no matter what i try
    i just dont understand what is happening, since it worked before



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/10/2009 at 16:15, xxxxxxxx wrote:

    You never gDelete(rnd). Except for AutoAlloc_<__>_, whenever you allocate memory (gNew, bNew, Alloc(), GeAlloc()) you MUST free it (gDelete(), bDelete(), Free(), GeFree()).



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/10/2009 at 16:21, xxxxxxxx wrote:

    thank you very much! now i just wonder why those memory leaks didnt appear in the past??

    cheers, ello



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/10/2009 at 19:58, xxxxxxxx wrote:

    No idea. I had something similar with SetPhong() creating new a phong tag no matter what but the memory pointer to the original continued to work until R11.5.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/10/2009 at 06:41, xxxxxxxx wrote:

    i am still with r11 since the 11.5 demo seems to not support the debug console



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/10/2009 at 07:18, xxxxxxxx wrote:

    Quote: Originally posted by kuroyume0161 on 09 October 2009
    >
    > * * *
    >
    > No idea. I had something similar with SetPhong() creating new a phong tag no matter what but the memory pointer to the original continued to work until R11.5.
    >
    >
    > * * *

    R11.5 contains new memory allocation code that is faster, lock-free (multiple threads can alloc memory at the same time without any performance hit) and has additional checks to catch memory trashers.

    With the old memory code it could happen, that you accidentally released memory in part A of your code, made a new allocation (of the same size) in part B of your code and accidentally got the same memory block with the data still intact back (and you never were aware of this fatal flaw in your code!). With R11.5 you will notice these bugs.

    Best regards,

    Wilfried Behne



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2009 at 10:13, xxxxxxxx wrote:

    One question, why don't you just do:

    > Real zufall (Real scale, int seed) \> { \> Random rnd; \> rnd.Init(seed); \> return rnd.GetG11()\*scale; \> } \>

    ?

    Cheers,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2009 at 10:53, xxxxxxxx wrote:

    hey jack.. that question is just so good that i cannot answer :D

    thanks for pointing it out ...

    cheers,
    ello



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 11/10/2009 at 11:02, xxxxxxxx wrote:

    Yes, you can do that. It is simply created on the stack instead of the heap and is removed from the stack at exit of the function.


Log in to reply