Memory leak with new NxOgre::World (Rev. 34) ?

Rhys

03-09-2007 04:24:59

I hope this wasn't posted before ^^ (Well, I didn't found it).

I don't know for sure if it is my fault, but there seems to be a memory leak (well, two of them) when creating new NxOgre World with the last revision (34).

pWorld = new NxOgre:World();
I would be glad if somebody could confirm that...otherwise I had to search for the error ;)

Additional info:
The memory leaks are caused by exactly this line, but they are not related to each other (one at 0x0053E758 and one at 0x0B7C3260 in my last run, both with 00 00 00 ... memory at this position).

betajaen

03-09-2007 09:39:16

You ARE deleting pWorld aren't you?

Rhys

03-09-2007 12:30:31

Yes, I do so.
It worked before without memory leak, just since yesterday it is not correct any more...and yesterday I updated to rev. 34.

betajaen

03-09-2007 12:46:18

Any chance you can narrow it down? World creates an insane amount of objects. It's like saying Ogre's Root creates a leak.

Rhys

03-09-2007 12:54:01

:) Yeah, that's right.

I'll try to have a look at the whole thing, but if you "well, I have no memory leaks with the current version" than it might be also a mistake by myself.

Hm, or maybe it is because of the serialisation? In NxOgreSerialiser.cpp there was the line
#ifdef (NX_USE_JSON == 1) || (NX_USE_TINYXML == 1 )
#include "NxOgreNxSerialiser.h"
#endif

I had to remove the #ifdef, 'cause I am neither using json nor tinyxml, but in line 130 the mNxOgreSerialiser member was used and without the include mentioned above the underlaying class was not known (I hope you unterstand ^^).

Rhys

03-09-2007 13:23:49

Hmmm....it may be caused by the UserAllocator class. As far as I can see there is a mem block allocated, but never freed, because the destructor is returning immediately.

The allocation is within a #ifdef _DEBUG block, the deallocation would be in #define NX_DEBUG

Maybe that is the problem.

Rhys

01-10-2007 14:52:04

Affirmation - it IS the user allocator :)
The destructor of the UserAllocator class never allows to delete the mMemBlockList, if NX_DEBUG is not defined.

betajaen

01-10-2007 15:18:09

I wrote my own UserAllocator class, so you shouldn't have any leaks with it. Expect it in the latest revision.

But thanks for tracking it down for me.