From efd0e0d1bdbaf5a5d5ff469a5fd7efdf9db446be Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 26 Apr 2016 15:14:30 +0300 Subject: Add memory count functions into ResourceManager. --- src/resources/resourcemanager.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/resources/resourcemanager.cpp') 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::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::iterator, it, mDeletedResources) + { + sz += (*it)->calcMemory(level + 1); + } + return sz; +} -- cgit v1.2.3-70-g09d2