diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-04-26 15:14:30 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-04-26 15:14:30 +0300 |
commit | efd0e0d1bdbaf5a5d5ff469a5fd7efdf9db446be (patch) | |
tree | 9f8b74d79fdadc8e6de9d6fdd427c02096df2e8b /src/resources/resourcemanager.cpp | |
parent | 8486afa9e52f96361cbf2c822258d6c5799c47d8 (diff) | |
download | plus-efd0e0d1bdbaf5a5d5ff469a5fd7efdf9db446be.tar.gz plus-efd0e0d1bdbaf5a5d5ff469a5fd7efdf9db446be.tar.bz2 plus-efd0e0d1bdbaf5a5d5ff469a5fd7efdf9db446be.tar.xz plus-efd0e0d1bdbaf5a5d5ff469a5fd7efdf9db446be.zip |
Add memory count functions into ResourceManager.
Diffstat (limited to 'src/resources/resourcemanager.cpp')
-rw-r--r-- | src/resources/resourcemanager.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 366460a6b..54ffe2d8e 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -36,6 +36,7 @@ #endif // USE_OPENGL #include "resources/imagehelper.h" #include "resources/imageset.h" +#include "resources/memorymanager.h" #include "resources/sdlmusic.h" #include "resources/soundeffect.h" @@ -1065,3 +1066,33 @@ void ResourceManager::clearCache() while (cleanOrphans(true)) continue; } + +int ResourceManager::calcMemoryLocal() +{ + int sz = sizeof(ResourceManager); + FOR_EACH (std::set<SDL_Surface*>::iterator, it, deletedSurfaces) + { + sz += memoryManager.getSurfaceSize(*it); + } + return sz; +} + +int ResourceManager::calcMemoryChilds(const int level) +{ + int sz = 0; + FOR_EACH (ResourceIterator, it, mResources) + { + sz += (*it).first.capacity(); + sz += (*it).second->calcMemory(level + 1); + } + FOR_EACH (ResourceIterator, it, mOrphanedResources) + { + sz += (*it).first.capacity(); + sz += (*it).second->calcMemory(level + 1); + } + FOR_EACH (std::set<Resource*>::iterator, it, mDeletedResources) + { + sz += (*it)->calcMemory(level + 1); + } + return sz; +} |