vertex deallocation

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
ignorator
Posts: 13
Joined: Fri Sep 21, 2007 1:36 am

vertex deallocation

Post by ignorator »

Hi :D

I'm copying vertices from a mesh to a new structure.

the mesh is loaded like this:

Code: Select all

scene::IAnimatedMesh* testmesh = smgr->getMesh("../../media/test.3ds");
now I want to get rid of the old vertices in the testmesh.
When I call

Code: Select all

delete testmesh
I think the vertices remain in memory. Must I delete each vertex manually (by iterating through the vertex-buffers) ?

example from collision tutorial:

Code: Select all

// program using 9.272 K
scene::IAnimatedMesh* q3levelmesh = smgr->getMesh("20kdm2.bsp");
// program using 17.884 K
delete q3levelmesh;
q3levelmesh = 0;
// program using 14.960 K
memory leak?



greetings
ignorator[/code]
Dark_Kilauea
Posts: 368
Joined: Tue Aug 21, 2007 1:43 am
Location: The Middle of Nowhere

Post by Dark_Kilauea »

You should never call a delete on a pointer pointing to a mesh or a scenenode handled by irrlicht. Always call a ->drop(); See IUnknown for details.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

A handle to the mesh will still be in the mesh cache, so you need to remove it from there. Once you've removed it from the cache, and you drop your handle to the mesh, the memory usage should almost go back to the original state.

You only want to drop a handle if you have grabbed it. If you are removing meshes from the cache, then you should be grabbing them.

Travis
Last edited by vitek on Mon Oct 01, 2007 3:07 am, edited 1 time in total.
ignorator
Posts: 13
Joined: Fri Sep 21, 2007 1:36 am

Post by ignorator »

You should never call a delete on a pointer pointing to a mesh or a scenenode handled by irrlicht. Always call a ->drop(); See IUnknown for details.
I have looked at IUnknown. The comment said one sould only call drop() if the pointer was initialised via a createSomething().... method...
A handle to the mesh will still be in the mesh cache, so you need to remove it from there. Once you've removed it from the cache, and you drop your handle to the mesh, the memory usage should almost go back to the original state.
thx :D removing it from the cache helped.
Post Reply