diff options
author | Andrei Karas <akaras@inbox.ru> | 2016-04-28 17:30:18 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2016-04-28 17:30:18 +0300 |
commit | 37c4338e84265705ec41c5da03e325255a9bce63 (patch) | |
tree | d159e2db539aaf0f8e0d25c9d7ecde5fb37d8a98 | |
parent | 2c93aa0a1e25f39ab351a4f12c5fd7f188a528a2 (diff) | |
download | plus-37c4338e84265705ec41c5da03e325255a9bce63.tar.gz plus-37c4338e84265705ec41c5da03e325255a9bce63.tar.bz2 plus-37c4338e84265705ec41c5da03e325255a9bce63.tar.xz plus-37c4338e84265705ec41c5da03e325255a9bce63.zip |
Show object name/source in memory counting tree.
-rw-r--r-- | src/resources/memorycounter.cpp | 5 | ||||
-rw-r--r-- | src/resources/memorycounter.h | 5 | ||||
-rw-r--r-- | src/resources/memorymanager.cpp | 6 | ||||
-rw-r--r-- | src/resources/memorymanager.h | 5 | ||||
-rw-r--r-- | src/resources/resource.h | 3 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 3 |
6 files changed, 23 insertions, 4 deletions
diff --git a/src/resources/memorycounter.cpp b/src/resources/memorycounter.cpp index e42a2640d..5d5131644 100644 --- a/src/resources/memorycounter.cpp +++ b/src/resources/memorycounter.cpp @@ -37,7 +37,10 @@ int MemoryCounter::calcMemory(const int level) const { const int sumLocal = calcMemoryLocal(); const int sumChilds = calcMemoryChilds(level); - memoryManager.printMemory(level, sumLocal, sumChilds); + memoryManager.printMemory(getCounterName(), + level, + sumLocal, + sumChilds); return sumLocal + sumChilds; } diff --git a/src/resources/memorycounter.h b/src/resources/memorycounter.h index 94593b717..809a6196d 100644 --- a/src/resources/memorycounter.h +++ b/src/resources/memorycounter.h @@ -21,6 +21,8 @@ #ifndef RESOURCES_MEMORYCOUNTER_H #define RESOURCES_MEMORYCOUNTER_H +#include <string> + #include "localconsts.h" class MemoryCounter notfinal @@ -36,6 +38,9 @@ class MemoryCounter notfinal virtual int calcMemoryLocal() const; virtual int calcMemoryChilds(const int level) const; + + virtual std::string getCounterName() const + { return "unknown"; } }; #endif // RESOURCES_MEMORYCOUNTER_H diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp index 9d4befd30..2da7c0908 100644 --- a/src/resources/memorymanager.cpp +++ b/src/resources/memorymanager.cpp @@ -55,13 +55,15 @@ int MemoryManager::getSurfaceSize(const SDL_Surface *const surface) 10; } -void MemoryManager::printMemory(const int level, +void MemoryManager::printMemory(const std::string &name, + const int level, const int localSum, const int childsSum) { std::string str(level, ' '); - logger->log("%s%d = %d + %d", + logger->log("%s%s: %d = %d + %d", str.c_str(), + name.c_str(), localSum + childsSum, localSum, childsSum); diff --git a/src/resources/memorymanager.h b/src/resources/memorymanager.h index 9243989d3..58fdbbbb5 100644 --- a/src/resources/memorymanager.h +++ b/src/resources/memorymanager.h @@ -21,6 +21,8 @@ #ifndef MEMORYMANAGER_H #define MEMORYMANAGER_H +#include <string> + #include "localconsts.h" class ChatTab; @@ -39,7 +41,8 @@ class MemoryManager final int getSurfaceSize(const SDL_Surface *const surface); - void printMemory(const int level, + void printMemory(const std::string &name, + const int level, const int localSum, const int childsSum); diff --git a/src/resources/resource.h b/src/resources/resource.h index 90cea413c..4d9e03f2d 100644 --- a/src/resources/resource.h +++ b/src/resources/resource.h @@ -101,6 +101,9 @@ class Resource notfinal : public MemoryCounter int calcMemoryLocal() const override; + std::string getCounterName() const override + { return mIdPath + "-" + mSource; } + #ifdef DEBUG_DUMP_LEAKS bool getDumped() const A_WARN_UNUSED { return mDumped; } diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 8d952e207..651142e29 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -259,6 +259,9 @@ class ResourceManager final : public MemoryCounter int calcMemoryChilds(const int level) const override final; + std::string getCounterName() const override final + { return "ResourceManager"; } + static void init(); private: |