NxOgre's constructure problem?

kaneyxt

09-03-2010 02:20:12

I am using NxOgre in my program, and always get a crash after create/release NxOgre world for 10 times. This crash looks like some static memory buffer overflowing problem, here are some details:
1. My program is a MFC-based application, and NxOgre.lib is linked to the final exe file directly. So when my program starts, the NxOgre.dll, NxCooking.dll, PhysXLoader.dll will be loaded automatically. But at this time, there is no NxOgre world at all.
2. Then I can go to a windows which has a NxOgre world. In this world, I create one NxOgre Scene which has about 30 triggers and several dynamic actors. All the triggers are convex mesh, each mesh has about 20-50 vertexes. When the first time NxOgre world is created, PhysXCooking.dll and PhysXCore.dll will be loaded.
3. Then I quit the window and NxOgre world will be released, I call NxOgre::World::destroyWorld(true). But at this time, PhysXCooking.dll and PhysXCore.dll will NOT be unloaded!
4. I repeat step 2 and 3 for 10 times, at the 11th time, the program will crash!
So I guess maybe this crash is related to the memory buffer for convex mesh cooking or mesh management. As far as I know, PhysX has some vertex limit for convex mesh. If you do not unload PhysXCooking.dll and PhysXCore.dll, but just cook/create convex mesh again and again, some static memory buffer may be used up and cause the crash. Or is there similar problem in NxOgre's own mesh management system?
I know this is maybe a strange usage of NxOgre, but I also think this is a serious problem of NxOgre's constructure. As when I intergrate PhysX into other engine, such as Unreal3 and Gamebryo, after one scene is released, I always unload PhysXCooking and PhysXCore.

kaneyxt

09-03-2010 09:04:31

Well, I use the same triggers to create PhysX scene in Ogre directly. And I create/release the scene for over 300 times, the crash problem does not occur. In my test program, I unload PhysXCore.dll every time when scene is released.

betajaen

09-03-2010 09:42:47

It's more likely to be PhysX that hates to be created that many times. You need to treat NxOgre::World like the Ogre::Root, it's a singleton it should be only created once in your applications lifetime.

kaneyxt

10-03-2010 00:27:42

I don't think it is an issue of PhysX, as I said in the 2nd floor, I create/release PhysX with the same actors I use in NxOgre for 300 times, and it is OK. The difference is that the PhysXCore.dll will be unloaded every time when PhysX is released. But I do not unload it manually, after I call releaseSDK(), the dll will be unloaded automatically. So I am not sure why it does not happen when NxOgre world is released, as the PhysicsSDK will be released here. Also, the ogre root will be deleted when PhysX is released.
In my application, I do not want to keep ogre root or nxogre world alive for all the time. As the ogre/nxogre window is only part of the program. They will not be used sometimes. And each time ogre/nxogre window is loaded, they will use different model sets, and at this time, I do not manage the models by myself, so I can not release them manually. If I keep ogre root/nxogre world and load the scenes for several times, there will be thousands of models. So I choose to release ogre/nxogre completely every time.