MFC reloading ogre in runtime

Problems building or running the engine, queries about how to use features etc.
Post Reply
_lkoikm
Halfling
Posts: 57
Joined: Fri Feb 11, 2005 7:52 am
Location: Here.

MFC reloading ogre in runtime

Post by _lkoikm »

Hi.
As an newbie i welcome moderators and bossy people here...
I am coding an MFC application in .NET 2003 VC++
application uses ogre engine to present some models ...
since model presenting is only a part of project i create Root, window , and so on when it is needed and

Code: Select all

delete(mRoot);
when i want to finish rendering.
Problem is following..
what is proper way of getting rid of ogre ?
in demos ogre is only deleted but since applicaton is suddenly closed after it there is no problem with memory and other fallacies.
When i close ogre sometimes everything is fine , but after couple of reloads (in one run) program throws a an exception , almost everytime in random places (sometimes null ptr assigment) , which are called from plugins , or memory manager....
I am quite experienced programmer and i double checked other memory issues in my program to ensure that they don't interfere.
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 67
Contact:

Post by sinbad »

Deleting root should be enough. We have memory leak checking to catch any memory which hangs around, perhaps it's something else. We can't answer your question without a solid example of both the problem (stack trace) and the test case which created it.
_lkoikm
Halfling
Posts: 57
Joined: Fri Feb 11, 2005 7:52 am
Location: Here.

Post by _lkoikm »

ok, i solved some of the probems with quitting ogre and exceptions attaching mutexes on Root::RenderOneFrame() and ogre variables , that seemed to be a problem, still i got two other problems :
1 while running these lines

Code: Select all

im.load(b,ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
	  TextureManager::getSingleton().unload("TestTexture");
	  TextureManager::getSingleton().remove("TestTexture");
	  TexturePtr mTexture = TextureManager::getSingleton().loadImage( "TestTexture",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, im, TEX_TYPE_2D, -1, 1.0f ); 
4-5 times my textures chnage from
Image

everything is ok , no crashes but the materials on walls seem to be broken ( those are demo Examples/Bumpmapping.....)

and second problem :
ogreleaks.log
always has some leaks , and i managed to trace that following code generates them :

Code: Select all

ConfigFile::SectionIterator seci = cf.getSectionIterator();

		Ogre::String secName, typeName, archName;
		while (seci.hasMoreElements())
		{
			secName = seci.peekNextKey();
			ConfigFile::SettingsMultiMap *settings = seci.getNext();
			ConfigFile::SettingsMultiMap::iterator i;
			for (i = settings->begin(); i != settings->end(); ++i)
			{
				typeName = i->first;
				archName = i->second;
				ResourceGroupManager::getSingleton().addResourceLocation(
					archName, typeName, secName);
			}
		} 
		MaterialManager::getSingleton().initialise();
		MaterialManager::getSingleton().setDefaultAnisotropy(2);
MaterialManager::getSingleton().create( "haha",ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME );
			MaterialManager::getSingleton().create( "FileMaterial" ,ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
			//this->createTexture(Color::HotPink);
			
			ResourceGroupManager::getSingleton().initialiseAllResourceGroups();

and sample lines from ogreleaks.log :

52 memory leaks found:

Alloc. Addr Size Addr Size BreakOn BreakOn
Number Reported Reported Actual Actual Unused Method Dealloc Realloc Allocated by
------ ---------- ---------- ---------- ---------- ---------- -------- ------- ------- ---------------------------------------------------
008318 0x110EBB18 0x000001B4 0x110EBB08 0x000001D4 0x00000000 new N N ??(0) ??
008317 0x110EBEB0 0x00000020 0x110EBEA0 0x00000040 0x00000000 new N N ??(0) ??
008319 0x110EBF30 0x00000024 0x110EBF20 0x00000044 0x00000000 new N N ??(0) ??
008320 0x110EBFB0 0x00000044 0x110EBFA0 0x00000064 0x00000000 new N N ??(0) ??
008321 0x110F2498 0x00000044 0x110F2488 0x00000064 0x00000000 new N N ??(0) ??
008322 0x110F2538 0x00000044 0x110F2528 0x00000064 0x00000000 new N N ??(0) ??
008323 0x110F25D8 0x00000044 0x110F25C8 0x00000064 0x00000000 new N N ??(0) ??
Post Reply