Quick example pseudo code:
Code: Select all
matA = MaterialManager::getSingleton().create(...);
matA->load(); //adds xxx bytes to the ResourceManager::mMemoryUsage
matB = matA.clone(...); //adds nothing
matB->unload(); //removes xxx bytes from the ResourceManager::mMemoryUsage
matA->unload(); //removes xxx bytes from the ResourceManager::mMemoryUsage
After that, every time ResourceManager::checkUsage(void) is called, it'll say the memory budget is exceeded.
Simple fix proposal, add this at the end of the Material::clone method
Code: Select all
//if we're cloning from a loaded material, notify the creator or otherwise tracked size won't be right
if (newMat->getLoadingState() == LOADSTATE_LOADED)
{
// Notify manager
if (mCreator)
mCreator->_notifyResourceLoaded(newMat.get());
}