summaryrefslogtreecommitdiff
path: root/indra/llcommon/llmemory.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2023-11-30 18:09:29 +0200
committerAndrey Lihatskiy <alihatskiy@productengine.com>2023-11-30 18:09:29 +0200
commitc409236dacc215231e8404133c2613d5ee90c990 (patch)
tree25dfeec08de41090e466412d5ae8f5fe948c6146 /indra/llcommon/llmemory.cpp
parent683bf84bb38adc88d4a4b7fedaed89b41fcac45e (diff)
parentd2ade35b0914f86b1c0239dbf40f5d5972a11b07 (diff)
Merge branch 'DRTVWR-594-maint-Y' into marchcat/594-y-pbr-merge
# Conflicts: # indra/newview/llinventorygallery.cpp # indra/newview/skins/default/xui/en/notifications.xml
Diffstat (limited to 'indra/llcommon/llmemory.cpp')
-rw-r--r--indra/llcommon/llmemory.cpp30
1 files changed, 7 insertions, 23 deletions
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 7cdf7254ff..574b9b8b3b 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