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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Memory Leak when RemoveTag()

    Scheduled Pinned Locked Moved SDK Help
    14 Posts 0 Posters 1.0k 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 09/04/2008 at 09:28, xxxxxxxx wrote:

      OK i tried this before, but then Cinema crashes. Maybe i post more of my code:

          
          
          
          
          class MyTag : public TagData  
          {  
             ...  
          }
          
          
          
          
          BaseTag* tag = op->MakeTag(ID_MYTAG);  
          tag->Remove();  
          BaseTag::Free(tag);
          
          
          
          
          
      
      When i try this, cinema crashes ...
      
      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 09/04/2008 at 09:34, xxxxxxxx wrote:

        It should be something like this:

        > \> PluginTag \*tag = (PluginTag\* )op->MakeTag(ID_MYTAG); \> if(tag) \> { \>      tag->Remove(); \>      PluginTag::Free(tag); \> } \>

        cheers,
        Matthias

        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 09/04/2008 at 09:36, xxxxxxxx wrote:

          If you get a compiler error, cast the tag:

          PluginTag:Free((PluginTag*&)tag);

          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 09/04/2008 at 12:53, xxxxxxxx wrote:

            THX

            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 14/04/2008 at 12:23, xxxxxxxx wrote:

              Another problem occured. I did it like Matthias told me, but with a little extension. There is a function which adds the tag with

                  
                  
                    
                  PluginTag *tag = (PluginTag* )op->MakeTag(ID_MYTAG);  
                  
              
              Another function should kill the tag and tries to do this with
              
                  
                  
                    
                  PluginTag *tag = (PluginTag* )op->GetTag(ID_MYTAG);  
                  tag->Remove();  
                  PluginTag::Free(tag);  
                  
              
              When i add the last line PluginTag::Free(tag) Cinema crashes. Any ideas?
              
              
              
              
               
              
              
              
              
              I also tried:  
              
                  
                  
                    
                  PluginTag *tag = (PluginTag* )op->GetTag(ID_MYTAG);  
                  op->KillTag(ID_MYTAG);  
                  
              
              with the same result....
              
              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 14/04/2008 at 13:31, xxxxxxxx wrote:

                if (!tag) // don't do anything

                If there is no tag retrieved by GetTag(), that could be problematic.

                If tag isn't NULL and the code is only crashing on PluginTag::Free(tag), then you'd better check your tag's Free() method for possible bad memory deallocations or illegal calls.

                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 14/04/2008 at 15:39, xxxxxxxx wrote:

                  Where are you freeing the tag? And what is "op"? In some threaded functions it is not allowed to modify the scene and if op is in the scene this may be what causes the crash.

                  Otherwise, as stated by the others, you must be missing another memory allocation as the code is fine (except for the pointer checks but let´s assume all objects are there).

                  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 20/04/2008 at 04:54, xxxxxxxx wrote:

                    Sorry guys,
                    wasn't there last week. I tried what you told me but the problem is still there. The thing is that the problem only occures when i allocate the tag in one function an free it in another. When i free it in the same function everything is fine ( but this doesn't make sense )
                    cheers
                    Peter

                    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 20/04/2008 at 05:15, xxxxxxxx wrote:

                      where are you allocating/freeing it exactly? What is the name of the functions? Is it your own functions? Where are you storing the pointer of the allocated tag?

                      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 20/04/2008 at 10:35, xxxxxxxx wrote:

                        I think more code would be warranted here. Since this is odd behavior, a small snippet doesn't provide the context necessary to answer Samir's questions in the previous post.

                        It could be a threaded situation or a situation where the scene must not be modified or you could be working with a cloned object (ModifyObject() or some render method). Hard to say without more information.

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