From 64815b311e47395638a2bf5ea80f949526942570 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 27 Apr 2016 02:53:46 +0300 Subject: Show counted memory usage sum in chat. --- src/actions/actions.cpp | 5 ++++- src/localconsts.h | 5 +++++ src/resources/memorymanager.cpp | 18 ++++++++++++++++-- src/resources/memorymanager.h | 4 +++- 4 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 1e7a9ad5b..9f7e5287a 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -1786,7 +1786,10 @@ impHandler(seen) impHandler0(dumpMemoryUsage) { - memoryManager.printAllMemory(); + if (event.tab) + memoryManager.printAllMemory(event.tab); + else + memoryManager.printAllMemory(localChatTab); return true; } diff --git a/src/localconsts.h b/src/localconsts.h index f5254c641..96943671e 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -93,6 +93,11 @@ #else // EATHENA_SUPPORT #define A_TMWA_UNUSED #endif // EATHENA_SUPPORT +#ifdef DYECMD +#define A_DYECMD_UNUSED __attribute__ ((unused)) +#else // DYECMD +#define A_DYECMD_UNUSED +#endif // DYECMD #ifdef __native_client__ #define restrict diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp index a88d53b79..ecb0879aa 100644 --- a/src/resources/memorymanager.cpp +++ b/src/resources/memorymanager.cpp @@ -22,8 +22,13 @@ #include "logger.h" +#include "gui/widgets/tabs/chat/chattab.h" + #include "resources/resourcemanager.h" +#include "utils/gettext.h" +#include "utils/stringutils.h" + #include #include @@ -62,10 +67,19 @@ void MemoryManager::printMemory(const int level A_UNUSED, childsSum); } -void MemoryManager::printAllMemory() +void MemoryManager::printAllMemory(ChatTab *const tab A_DYECMD_UNUSED) { if (!logger) return; + int sz = 0; if (resourceManager) - resourceManager->calcMemory(0); + sz += resourceManager->calcMemory(0); +#ifndef DYECMD + if (tab) + { + // TRANSLATORS: memory usage chat message + tab->chatLog(strprintf(_("Calculated memory usage: %d"), sz), + ChatMsgType::BY_SERVER); + } +#endif } diff --git a/src/resources/memorymanager.h b/src/resources/memorymanager.h index 658876776..9243989d3 100644 --- a/src/resources/memorymanager.h +++ b/src/resources/memorymanager.h @@ -23,6 +23,8 @@ #include "localconsts.h" +class ChatTab; + struct SDL_Surface; class MemoryManager final @@ -41,7 +43,7 @@ class MemoryManager final const int localSum, const int childsSum); - void printAllMemory(); + void printAllMemory(ChatTab *const tab); }; extern MemoryManager memoryManager; -- cgit v1.2.3-70-g09d2