CurrentStateToObj - Mem Leak (?)



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

    On 02/02/2004 at 00:17, xxxxxxxx wrote:

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

    ---------
    Hi
    i have a Memory Leak problem with a generator i'm writing. The generator has a BaseLink in the Description. And in GetVirtualObjects i'm doing something like this:

    GetVirtualObjects(...) 
    
    
    
    
    {
    
    
    
    
          BaseObject\* linked =  op->GetDataInstance()->GetLink(MYLINK,Obase,hh->GetDoc())
    
    
    
    
          ModelingCommandData md
    
    
    
    
          md.doc = hh->GetDoc()
    
    
    
    
          md.op = linked
    
    
    
    
          SendModelingCommand(md,CURRENT_STATE_TO_OBJECT);
    
    
    
    
          BaseObject \* polygonized_linked = md.result1
    
    
    
    
          // for debugging purpose free it at once
    
    
    
    
          BaseObject::Free(polygonized_linked)
    
    
    
    
          
    
    
    
    
          // for debugging purpose no changed to input objects
    
    
    
    
          return GetAndCheckHierarchyClone(....)   
    
    
    
    
    }
    
    
    
    
    
    
    
    The problem is that in a scene where "linked" points to a 
    
    SDS-Object a memory leak occured. It were only 24 bytes per 
    
    SendModelingCommand call. The DebugOutput said:
    
    
    
    
    "OperatingSystem, 1136 -> 24Bytes"
    
    
    
    
    I found this very odd. And i have no idea what is going on...
    
    
    
    
     
    
    
    
    
    Appreciate any Help :-)
    


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

    On 09/02/2004 at 17:54, xxxxxxxx wrote:

    First, please try to copy and paste code whenever possible. Shortening it down is fine, but the above contains many typos which have to be fixed before it compiles.
    As for the memory leak, my first attempt at reproducing it was unsuccessful. I created a scene with a HyperNURBS object with a cube inside, then an Atom object with the following code appended:

        
        
        BaseObject *AtomObject::GetVirtualObjects(PluginObject *op, HierarchyHelp *hh)  
        {  
          BaseObject* linked =    
            static_cast<BaseObject*>(  
              op->GetDataInstance()->GetLink(  
                ATOMOBJECT_SINGLE,hh->GetDocument(), Obase));  
          ModelingCommandData md;  
          md.doc = hh->GetDocument();  
          md.op = linked;  
          SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, md);  
          BaseObject * polygonized_linked = md.result1;  
          BaseObject::Free(polygonized_linked);
    

    And the following small change to the resource:

        
        
        LINK ATOMOBJECT_SINGLE { }
    

    Then I dragged the HyperNURBS to the link field and let the SendModelingCommand() function be called a few times. But no memory leak was reported.
    Could you try your code without the link (just using hh->GetDocument()->GetFirstObject()) to see if the link or the SendModelingCommand() call is the culprit?



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

    On 12/02/2004 at 12:59, xxxxxxxx wrote:

    Sorry for the extremly shortened code.
    I just tried the same thing as you, modifying the Atom object, as you did above. I was able to get the memory leak. The setup was the same as yours: a SDS object with a polygon cube as child. However i had to set the "UV subdivide" option to "edge", for the leak to occur. Then i just enabled/disable the Atomobject a few times, so the GetVirtualObject functions gets called.
    I can hardly believe that there is something wrong with the SDS. So could could you try this, too.
    Thanks for your help
    Michael



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

    On 22/02/2004 at 09:14, xxxxxxxx wrote:

    Meanwhile the problem was found.
    In case you are interested, it IS a problem with the SDS object. Whenever CurrentStateToObject is called, and if "uv subdivision" is set to "edge" or "boundary", some bytes are lost.
    I could have seen it much earlier, since it happens with the CurrentStateToObject user command in Cinema, too.


Log in to reply