I try to release memory at runtime.
Why memory couldn’t be released when i work with convex meshes.
My process:
Scene.simulate()
Scene.fetchResult()
…
My deleting process steps:
- release all materials
- release all shapes
- release all actors
- release all convex meshes (before invoke release reference count is 1)
…
Scene.simulate()
Scene.fetchResult()
I’m doing the same, and have no leaks on PhysX 3.3.
But I do scene.release() after releasing all objects, and CreateScene(scene) before starting simulation again. Try to release scene.
I can’t release scene, because i should have the option to delete x actors (not all) and create as many as i need.
Example:
I have 20 vehicles(with many rigidbodys and shapes). All of them have some transport orders and driving in the scene. Then i want delete 10 of them and create x new cars.
I’ve watched my code. I’m releasing convex mesh after coocking. And at the time I don’t need it more, I release actor that the mesh attached.
Like that:
//Cooking was good
if(bIsCookedOK)
{
//Creating mesh
PxToolkit::MemoryInputData input(buf.getData(), buf.getSize());
PxConvexMesh *convexMesh = pGlobalPhysics->createConvexMesh(input);
//if mesh was created, assign it to actor
if (convexMesh)
{
pShape = pDynActor->createShape( PxConvexMeshGeometry(convexMesh),*CurrentMaterial,NG2MatToPxTransform(matG));
}
convexMesh->release();
}
. . .
pDynActor->release();
Don’t you forget to release that temporary thing?