Heap fragmentation prevention on Win32
Posted: Fri Jun 24, 2011 12:29 pm
I recently ran into a heap fragmentation issue.
Ogre failed to allocate around 18MB whereas the WorkingSetSize returned was around 1GB. In my app user travels between fixed locations a lot causing them to load and unload tons of objects, each if which is wrapped in a fairly large number Ogre3D class instances. I have been suggested to use this after each delete:
And when set after inbetween-scene reloads, it effectively got rid of the problem.
My point is to extend OGRE_FREE, OGRE_DELETE_T, OGRE_DELETE_ARRAY_T, OGRE_DELETE, OGRE_DELETE_ARRAY_T_ALIGN, OGRE_DELETE_T_ALIGN, OGRE_DELETE_ARRAY_T_SIMD and OGRE_DELETE_T_SIMD macros with calls to this function to prevent this happening OR include that in ResourceManagers' unload* methods. It's not much of a work and can save some head scratching in particular circumstances.
So, my final question is, do you think it's a good idea, or does the user need to do that kind of stuff himself.
Ogre failed to allocate around 18MB whereas the WorkingSetSize returned was around 1GB. In my app user travels between fixed locations a lot causing them to load and unload tons of objects, each if which is wrapped in a fairly large number Ogre3D class instances. I have been suggested to use this after each delete:
Code: Select all
SetProcessWorkingSetSize( GetCurrentProcess(), -1, -1 );
My point is to extend OGRE_FREE, OGRE_DELETE_T, OGRE_DELETE_ARRAY_T, OGRE_DELETE, OGRE_DELETE_ARRAY_T_ALIGN, OGRE_DELETE_T_ALIGN, OGRE_DELETE_ARRAY_T_SIMD and OGRE_DELETE_T_SIMD macros with calls to this function to prevent this happening OR include that in ResourceManagers' unload* methods. It's not much of a work and can save some head scratching in particular circumstances.
So, my final question is, do you think it's a good idea, or does the user need to do that kind of stuff himself.