diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-05-22 09:30:04 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-05-22 09:30:04 -0400 |
commit | eb81d5f23fc725f53857d7a62923e273a057c455 (patch) | |
tree | 5c1ba76e722d9630fa597023a1e6c196a04f758c /indra/llcommon/llmemory.cpp | |
parent | f8ccb39b8d944f9d2bf4308f909273cd5a35cbe7 (diff) | |
parent | 47985e5822ce9fdebb7443e13b3c1a781a842ecd (diff) |
Merge remote-tracking branch 'DRTVWR-600-maint-A' into nat/kwds
Diffstat (limited to 'indra/llcommon/llmemory.cpp')
-rw-r--r-- | indra/llcommon/llmemory.cpp | 30 |
1 files changed, 7 insertions, 23 deletions
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index 196114cee9..6e0715d697 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -38,6 +38,7 @@ #include <mach/mach_host.h> #elif LL_LINUX # include <unistd.h> +# include <sys/resource.h> #endif #include "llmemory.h" @@ -273,33 +274,16 @@ U64 LLMemory::getCurrentRSS() U64 LLMemory::getCurrentRSS() { - static const char statPath[] = "/proc/self/stat"; - LLFILE *fp = LLFile::fopen(statPath, "r"); - U64 rss = 0; + struct rusage usage; - if (fp == NULL) - { - LL_WARNS() << "couldn't open " << statPath << LL_ENDL; + if (getrusage(RUSAGE_SELF, &usage) != 0) { + // Error handling code could be here return 0; } - // Eee-yew! See Documentation/filesystems/proc.txt in your - // nearest friendly kernel tree for details. - - { - int ret = fscanf(fp, "%*d (%*[^)]) %*c %*d %*d %*d %*d %*d %*d %*d " - "%*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %Lu", - &rss); - if (ret != 1) - { - LL_WARNS() << "couldn't parse contents of " << statPath << LL_ENDL; - rss = 0; - } - } - - fclose(fp); - - return rss; + // ru_maxrss (since Linux 2.6.32) + // This is the maximum resident set size used (in kilobytes). + return usage.ru_maxrss * 1024; } #else |