diff --git a/source/App/DecoderApp/decmain.cpp b/source/App/DecoderApp/decmain.cpp index da4a11119dfe2176d955a2b3e11fd3e31fbc88d2..8f3d41e3f176729ac4793b66498909332c87aa4e 100644 --- a/source/App/DecoderApp/decmain.cpp +++ b/source/App/DecoderApp/decmain.cpp @@ -112,6 +112,14 @@ int main(int argc, char* argv[]) } #endif + #if JVET_Z0150_MEMORY_USAGE_PRINT +#ifdef __linux + int vm = getProcStatusValue("VmPeak:"); + int rm = getProcStatusValue("VmHWM:"); + printf("\nMemory Usage: VmPeak= %d KB ( %.1f GiB ), VmHWM= %d KB ( %.1f GiB )\n", vm, (double)vm/(1024*1024), rm, (double)rm/(1024*1024)); +#endif +#endif + // ending time dResult = (double)(clock()-lBefore) / CLOCKS_PER_SEC; printf("\n Total Time: %12.3f sec.\n", dResult); diff --git a/source/App/EncoderApp/encmain.cpp b/source/App/EncoderApp/encmain.cpp index a2051d7a31e920c320d03631908de72728956673..65a2494cc9d0a02b33bcb3e0e37bc8f2adc9865f 100644 --- a/source/App/EncoderApp/encmain.cpp +++ b/source/App/EncoderApp/encmain.cpp @@ -77,33 +77,6 @@ static void printMacroSettings() } } -#if JVET_Z0150_MEMORY_USAGE_PRINT -#ifdef __linux -#include <cstdlib> -#include <cstdio> -#include <cstring> - -int getProcStatusValue(const char* key) -{ - FILE* file = fopen("/proc/self/status", "r"); - int result = -1; - char line[128]; - - int len = strlen(key); - while (fgets(line, 128, file) != nullptr) - { - if (strncmp(line, key, len) == 0) - { - result = atoi(line+len); - break; - } - } - fclose(file); - return result; -} -#endif -#endif - // ==================================================================================================================== // Main function // ==================================================================================================================== diff --git a/source/Lib/CommonLib/CommonDef.h b/source/Lib/CommonLib/CommonDef.h index 7b97928705afcda72cd022f24adf4d0453a70033..b61574718325c0a8c4f60d0191451332eb2efe3d 100644 --- a/source/Lib/CommonLib/CommonDef.h +++ b/source/Lib/CommonLib/CommonDef.h @@ -1817,6 +1817,29 @@ static inline uint32_t getIndexMappingTableToSortedArray1D(InputValueType (&in)[ } #endif +#if JVET_Z0150_MEMORY_USAGE_PRINT +#ifdef __linux +static inline int getProcStatusValue(const char* key) +{ + FILE* file = fopen("/proc/self/status", "r"); + int result = -1; + char line[128]; + + int len = strlen(key); + while (fgets(line, 128, file) != nullptr) + { + if (strncmp(line, key, len) == 0) + { + result = atoi(line+len); + break; + } + } + fclose(file); + return result; +} +#endif +#endif + //CASE-BREAK for breakpoints #if defined ( _MSC_VER ) && defined ( _DEBUG ) #define _CASE(_x) if(_x)