Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    memory leaks / what does this mean now

    Scheduled Pinned Locked Moved SDK Help
    15 Posts 0 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

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

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

      3 😉 and thats just because the password email doesnt work.. i already sent a mail to maxon but didnt got a response so far.. i'd be glad to use my original "ello" account again

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

        On 11/05/2009 at 14:22, xxxxxxxx wrote:

        i found that this line is responsible:

        > `

          
        \>  op = (BaseObject* )(profile->GetClone(0, NULL));  
        \>  
        

        `

        but using Free(op); doesnt help...

        profile is created here:
        > `

          
        \>  BaseObject *profile = (BaseObject* )(bc- >GetLink(PROFILE,op->GetDocument()));  
        \>  
        

        `

        any further hints?

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          On 11/05/2009 at 14:47, xxxxxxxx wrote:

          BaseObject* profile = bc->GetObjectLink(PROFILE, op->GetDocument());
          if (!profile) // do something

          Always check for NULL in cases like this (the user could clear the LINK)!

          What are you doing with the clone?

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

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

            On 11/05/2009 at 15:10, xxxxxxxx wrote:

            the full part already looks like this:

            > `

              
            \>  BaseObject *op = BaseObject::Alloc(Osplinecircle);  
            \>  if (profile)   
            \>  {  
            \>  profile ->SetEditorMode(MODE_OFF);  
            \>  profile->SetRenderMode(MODE_OFF);  
            \>  op = (BaseObject* )(profile->GetClone(0, NULL));  
            \>  }  
            \>  profile->InsertUnderLast(sweep);  
            \>  
            

            `

            if i dont uses the LINK the leaks dont appear

            btw. this all happens in a for-loop

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

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

              On 11/05/2009 at 15:42, xxxxxxxx wrote:

              You should move profile->InsertUnderLast(sweep) into the if{} block just in case profile is NULL, otherwise the code may crash.

              You allocate to op instead of profile. I hope that is just a typing error here or is profile coming from someplace else?

              You may need to create an AliasTrans and see if that removes the leaks from GetClone(). Normally you need one if the clone is going into another document than the one inwhich the original resides.

              Finally, are you calling BaseObject::Free(op) in the for loop? Otherwise you would only be freeing the last iteration.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

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

                On 11/05/2009 at 21:52, xxxxxxxx wrote:

                yes, that was a typo. its "op" which is inserted..

                i'll check that with the AliasTrans.. the manual sayi it can be NULL.. but i'll see what the manual offers about that..

                I used the Free(op); inside the loop but that doesnt help

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

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

                  On 11/05/2009 at 22:12, xxxxxxxx wrote:

                  Okay. 🙂

                  AliasTrans can be NULL, but in the case of cloning into other documents it should not. The reason is that AliasTrans does the 'reassigning' in such cases (such as when the object has a link which isn't cloned and doesn't exist in the new document, it will clear it accordingly, and so on).

                  Still, I'm not sure if the GetClone() is the only cause of the leaks. Is it definitive or circumstantial?

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

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

                    On 12/05/2009 at 02:48, xxxxxxxx wrote:

                    just to clarify, i am not cloning it into another document.

                    the leaking appears as soon as i use this line:
                    op = (BaseObject* )(profile->GetClone(0, NULL));

                    when i comment it out, everything is fine 🙂

                    btw. it only happens when i have dragged something into the link field and the condition "if(profile)" is true

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

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

                      On 12/05/2009 at 04:45, xxxxxxxx wrote:

                      definately has something to do with the combination of cloning the linked object since using a child object (op->GetDown(); does work with this line:

                      > `

                        
                      \>  BaseObject *clone = static_cast<BaseObject*>(child->GetClone(0, NULL));  
                      \>  
                      

                      `

                      any ideas?

                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

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

                        On 12/05/2009 at 08:35, xxxxxxxx wrote:

                        Instead of:
                        BaseObject *op = BaseObject::Alloc(Osplinecircle);

                        do:
                        Baseobject* op = NULL;

                        You don´t need to allocate op if you fill it with a clone later on. C4D does the memory allocation for the clone internally when you call GetClone().

                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

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

                          On 12/05/2009 at 08:42, xxxxxxxx wrote:

                          thanks! that was my idea to have at least a splinecircle when the user didnt drag a spline to the link field.

                          but just a second ago i found out that somehow exactly that creation of the circle beforehand was the issue. now there is no leaking and i am just feeling lighter now 😄

                          thanks for all your help here!

                          this is how i do it now:

                          > `

                            
                          \>    
                          \>                 if(profileLink)       
                          \>                 {  
                          \>                      BaseObject *profile = static_cast<BaseObject*>(profileLink->GetClone(0, NULL));  
                          \>                      profile->InsertUnderLast(sweep);  
                          \>                 }  
                          \>  
                          

                          `

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post