THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 13/07/2008 at 18:45, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 10
Platform:
Language(s) : C++ ;
---------
Hi,
i discovered that i have loads of mem leaks in my plugin, when i check the debug console.
Im not sure why bc i always use autoalloc, and when i 'remove' an object i always free it myself afterwards.
i tracked down the leaks to this function, so it must be something inside this piece of code:
> \> /\*\* \> convert obj and all of its children in to one poly object and return it \> \*\*/ \> BaseObject\* MyTool::getPolyObject(BaseObject\* obj,BaseDocument\* doc){ \> \> // make a copy of the object \> BaseObject \*copy = (BaseObject\* )obj->GetClone(COPY_NO_ANIMATION,NULL); \> copy->SetPos(Vector(0,0,0)); copy->SetRot(Vector(0,0,0)); \> \> // convert to polys \> ModelingCommandData md1; md1.op = copy; md1.doc = doc; \> if(!SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, md1)) return NULL; \> \> // select all objects in group \> md1.op = static_cast<BaseObject\*>(md1.result->GetIndex(0)); \> if(!SendModelingCommand(MCOMMAND_SELECTALL, md1)) return NULL; \> \> // connect all \> md1.op = static_cast<BaseObject\*>(md1.result->GetIndex(0)); \> if(!SendModelingCommand(MCOMMAND_JOIN, md1)) return NULL; \> \> // do an optimize ( cant hurt probably ..) \> md1.op = static_cast<BaseObject\*>(md1.result->GetIndex(0)); \> if(!SendModelingCommand(MCOMMAND_OPTIMIZE, md1)) return NULL; \> \> BaseObject\* result = static_cast<BaseObject\*>(md1.result->GetIndex(0)); \> \> return result; \> } \>
the code works, but it creates lots of mem leaks..
can anybody see what's wrong with this ?
i tried to free the copy object, but that makes cinema crash..
thanks in advance for your help