THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 29/09/2008 at 07:17, xxxxxxxx wrote:
Cinema 4D Version:
Language(s) : C++ ;
im using the colliderCache in my code and have problems with mem leaks (again ). the code is based on the api example.
Bool FillColliderCache(GeColliderCache& c, BaseObject* obj,BaseDocument* doc)
PolygonObject* poly = NULL;
// create a CSTO'd and joined copy. this function has no mem leaks!
BaseObject* objCopy = getPolyObject(obj,doc);
md1.op = objCopy; md1.doc = doc;
if(!SendModelingCommand(MCOMMAND_TRIANGULATE, md1)) goto Error;
poly = (static_cast<PolygonObject*>(md1.op));
if (!poly) goto Error;
// Get the polygon data
Polygon* tris = poly->GetPolygon();
Vector* points = poly->GetPoint();
CPolygon* tris = poly->GetPolygonW();
Vector* points = poly->GetPointW();
// Fill the cache with the tri's
// if i comment out this block, the mem leaks are gone..
if (c.BeginInput(poly->GetPolygonCount()) != COL_OK) goto Error;
for (int i = 0; i < poly->GetPolygonCount(); ++i)
if (c.AddTriangle(points[tris _.a], points[tris _.b], points[tris _.c], i) != COL_OK) goto Error;
if (c.EndInput() != COL_OK) goto Error;
//GeFree(points); // crash!
//GeFree(tris); // crash!
//BaseObject::Free(md1.op); // crash!
i thought the leaks were due to not freed points, tris and md1.op. But the problem is that cinema crashes when i try to free any of these..
When i outcomment the part were i store the tri's in the collidercache, the leaks are gone..
The collidercache itself is declared outside by autoalloc, so i assumed that all its data would be free'd automatically ?
In that regard I also trie the freePairsList() on the colliderCache, but that made no difference.