NULL pointer crash in OgreMain (1.9 version)

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
mageonline
Gnoblar
Posts: 10
Joined: Tue Aug 11, 2015 7:22 am
Location: Finland
Contact:

NULL pointer crash in OgreMain (1.9 version)

Post by mageonline »

Hi,

There is a null pointer crash in OgreMain.dll around 225000 iterations inside the g_scene->createEntity() call.

Is there a way to increase Ogre's memory pool?

Code: Select all

void createScene2()
{
	Entity * en;

	for (int i = 0; i < 500000; i++)
	{
		char t[100];

		sprintf(t, "ttn%d", i);

		Ogre::SceneNode * node = g_scene->getRootSceneNode()->createChildSceneNode(t, Ogre::Vector3(float16() * 1000, float16() * 1000, float16() * 1000));

		sprintf(t, "tte%d", i);

		en = g_scene->createEntity(t, "spade.mesh");
		if (en)
		{
			en->setQueryFlags(0);
			node->attachObject(en);
			node->setVisible(false);
		}
	}
}
OgreMovableObject.cpp - the crash is after the unchecked 'm'. Perhaps an "if (m == NULL) return m;" could be added in a hotfix 1.9 release?

Code: Select all

	MovableObject* MovableObjectFactory::createInstance(
		const String& name, SceneManager* manager, 
		const NameValuePairList* params)
	{
		MovableObject* m = createInstanceImpl(name, params);
		m->_notifyCreator(this);
		m->_notifyManager(manager);
		return m;
	}
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: NULL pointer crash in OgreMain (1.9 version)

Post by frostbyte »

not realy sure about c++ heap or mem stuff, but i guess that your bound to hit cpu/gpu memory ceiling at some point...
rather than increase memory( use 64bit compiler/buy new gpu/add memory ) i suggest you focus on lowering your app memory requirments
you can use Instancing for sharing the same vertics buffer between different entities( look at the Instancing demo on the Ogre sampleBrowser )
you can reduce your mesh polygon count( keywords: mesh Reduce, mesh lod, progressive mesh... demo on the ogre sampleBrowser )
you can unload/reload resources as neccessery at runtime( this is quite tricky... )
use different Lods in your app( best example is PagedGeometry plugin )...and so on( lot of other nasty tricks... )
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: NULL pointer crash in OgreMain (1.9 version)

Post by dark_sylinc »

frostbyte is right. At 225000 Entitys you're definitely going to start seeing memory problems.

The solution is to use the LARGEADRESSAWARE hack, or go full 64-bit. Or create less Entity (specially if they're static, consider combining their meshes). Using Ogre 2.x may also help since the memory footprint per Entity and per Node has been significantly reduced. But eventually you're always going to a hit a limit.
User avatar
mageonline
Gnoblar
Posts: 10
Joined: Tue Aug 11, 2015 7:22 am
Location: Finland
Contact:

Re: NULL pointer crash in OgreMain (1.9 version)

Post by mageonline »

Thanks!

The /LARGEADDRESSAWARE linker flag was the quick and dirty solution for now :)
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: NULL pointer crash in OgreMain (1.9 version)

Post by frostbyte »

LARGEADRESSAWARE?
cons:
http://stackoverflow.com/questions/2288 ... xecutables
https://ogre3d.atlassian.net/browse/OGRE-178

don't forget its sort of a hack...so use it with caution...
you'll just need to test/debug an "above 2gb mem allocation scenerios"...

pros:
quick hack
there is an important advantage for the remaining 32bit users http://store.steampowered.com/hwsurvey
commercial software is shiped with this flag( no need for two versions ), so i guess it's ok if tested well...
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
Post Reply