Resource unloading strategy

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
MadWatch
Halfling
Posts: 64
Joined: Sat Jul 06, 2013 11:25 am
x 4

Resource unloading strategy

Post by MadWatch »

Hello everyone.

During the past few days I've been coding my own resource management system that is capable of pre-loading resources (meshes and textures for the moment, skeletons soon hopefully) into a separated thread. It works well but there's one thing I'm not happy about : unloading.

My system use reference counting, when a resource use count drop to zero it is unloaded almost immediately (actually it's unloaded at the end of the current frame). I think that's stupid because sometimes a resource is released and re-acquired soon after. My system is capable of "saving" a resource that has been marked for unloading, but if the resource is already being unloaded, then it has to wait until it is fully unloaded and load it again, such a waste :(

So it would be much more efficient if the system would only start unloading resources when it has too. Like when it's running low on memory. Until then the unused resources could just sit in the ToBeUnloaded queue and be saved if they are needed again, skipping useless unloading/reloading step. But how could the system know that it has to unload resources ?

I know Ogre ResourceManager has a memory budget system. Did anyone use it ? If so then how did you figure out the memory budget for each kind of resource ?

Aside from tracking memory usage, is it possible to track GPU memory usage ? Would that even make sense in this situation ? Does anyone know a better strategy to handle resource unloading ?

Thanks
Post Reply