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

    Path Selection Tool memory leak

    Scheduled Pinned Locked Moved Bugs
    2 Posts 0 Posters 954 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

      On 08/06/2018 at 02:05, xxxxxxxx wrote:

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

      ---------
      Hello,

      For a while now I have been trying to fix memory leaks in my plugin, without success.
      Reason of this non-success is because the memory leak isn't actually happening inside of my plugin. It apparently is an issue with the Path Selection Tool.

      I have written the following plugin which does ... well, absolutely nothing.

      // ========================  
      // Testing  
      // Dummy "empty" plugin  
      // ========================  
        
      #include "c4d.h"  
        
      // Dummy IDs - for demonstration purposes only  
      #define MYCOMMAND_PLUGIN_ID    1999999 // Dummy ID for testing purposes  
        
      // ====================================  
      // CommandData  
      // ====================================  
        
      class MyCommand : public CommandData  
      {  
        INSTANCEOF(MyCommand, CommandData)  
        
      public:  
        virtual Bool Execute(BaseDocument* doc);  
        virtual Bool ExecuteSubID(BaseDocument* doc, Int32 subid);  
        virtual Int32 GetState(BaseDocument* doc);  
        virtual Bool RestoreLayout(void* secret);  
        virtual Bool Message(Int32 type, void* data);  
      };  
        
      Bool MyCommand::Execute(BaseDocument* doc)  
      {  
        return TRUE;  
      }  
        
      Bool MyCommand::ExecuteSubID(BaseDocument* doc, Int32 subid)  
      {  
        return TRUE;  
      }  
        
        
      Int32 MyCommand::GetState(BaseDocument* doc)  
      {  
        return CMD_ENABLED;  
      }  
        
      Bool MyCommand::RestoreLayout(void* secret)  
      {  
        return TRUE;  
      }  
        
      Bool MyCommand::Message(Int32 type, void* data)  
      {  
        return SUPER::Message(type, data);  
      }  
        
      Bool RegisterMyCommand(void)  
      {  
        return RegisterCommandPlugin(MYCOMMAND_PLUGIN_ID, "Testing", 0, AutoBitmap("icon.png"), "Test", NewObjClear(MyCommand));  
      }  
        
      // ====================================  
      // Plugin Main   
      // ====================================  
      Bool PluginStart(void)  
      {  
        RegisterMyCommand();  
        return TRUE;  
      }  
      void PluginEnd(void)   
      {  
      }  
      Bool PluginMessage(Int32 id, void * data)  
      {  
        switch (id) {  
        case C4DPL_INIT_SYS:  
            if (!resource.Init())  
                return FALSE;  
            return TRUE;  
        case C4DMSG_PRIORITY:  
            return TRUE;  
        case C4DPL_BUILDMENU:  
            break;  
        case C4DPL_ENDACTIVITY:  
            return TRUE;  
        }  
        return FALSE;  
      }  
      

      I run the above plugin (built with R19 SDK) via debugger.
      I create a default plane (20x20), make it editable, go to edge mode, enable the path selection tool via shortcut U, M, and start selecting edges. Creating new selection, adding, subtracting, ...
      then I close Cinema 4D and Visual Studio mentions following memory leak.

      Memory Leaks Detected:  
      p:\c4d_perforce_work\release\19.0\modules\c4dplugin\source\src\philip\objects\polygonobject.cpp (12417) : Memory leak of 401 bytes () at 0000000119535480  
      1 blocks not freed  
      
      

      I then run another debug session and do exactly the same, except that I now only use the Live Selection Tool, and DO NOT engage the Path Selection Tool at any time.
      Close Cinema ... no memory leaks.

      It seems that the more edges are selected with the Path Selection Tool the larger the memory leak is.

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

        On 11/06/2018 at 05:18, xxxxxxxx wrote:

        Hi,

        good find! I can reproduce the leak. Thanks for making us aware, I'll pass it on to development.

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