diff options
author | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-07-18 07:45:50 +0300 |
---|---|---|
committer | Andrey Lihatskiy <alihatskiy@productengine.com> | 2024-07-18 07:45:50 +0300 |
commit | adc058a6e06c8f532f4c0406c65694e87d86d707 (patch) | |
tree | 58ce8199ebe45200152a557e6801c61cbde34b92 /indra/llcommon/llsys.cpp | |
parent | 5482d6a92fcc2eb4f8506a521c2386849a2e9172 (diff) | |
parent | a65bc46b138b89200586b29fe729cbc7b0f0c8c4 (diff) |
Merge branch 'release/maint-b' into marchcat/b-develop
# Conflicts:
# autobuild.xml
# indra/cmake/JsonCpp.cmake
# indra/llimage/llimageworker.cpp
# indra/llmessage/CMakeLists.txt
# indra/llprimitive/llmodel.cpp
# indra/llprimitive/llmodelloader.cpp
# indra/llprimitive/llmodelloader.h
# indra/llwindow/llkeyboard.cpp
# indra/llwindow/llkeyboard.h
# indra/llwindow/llkeyboardheadless.cpp
# indra/llwindow/llkeyboardheadless.h
# indra/llwindow/llkeyboardsdl.cpp
# indra/llwindow/llkeyboardsdl.h
# indra/llwindow/llwindowsdl.cpp
# indra/llwindow/llwindowsdl.h
# indra/newview/app_settings/shaders/class1/deferred/screenSpaceReflUtil.glsl
# indra/newview/llappviewerlinux_api_dbus.cpp
# indra/newview/llconversationloglist.cpp
# indra/newview/lldirpicker.cpp
# indra/newview/llfilepicker.cpp
# indra/newview/llfloateremojipicker.cpp
# indra/newview/llfloaterpreferencesgraphicsadvanced.cpp
# indra/newview/llmodelpreview.cpp
# indra/newview/lloutfitslist.cpp
# indra/newview/llpanelface.cpp
# indra/newview/llviewerobject.h
# indra/newview/llxmlrpctransaction.cpp
# indra/newview/viewer_manifest.py
Diffstat (limited to 'indra/llcommon/llsys.cpp')
-rw-r--r-- | indra/llcommon/llsys.cpp | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp index 79625ad9f8..06b1855785 100644 --- a/indra/llcommon/llsys.cpp +++ b/indra/llcommon/llsys.cpp @@ -504,57 +504,46 @@ const S32 LLOSInfo::getOSBitness() const return mOSBitness; } -//static -U32 LLOSInfo::getProcessVirtualSizeKB() -{ - U32 virtual_size = 0; -#if LL_LINUX -# define STATUS_SIZE 2048 - LLFILE* status_filep = LLFile::fopen("/proc/self/status", "rb"); - if (status_filep) - { - S32 numRead = 0; - char buff[STATUS_SIZE]; /* Flawfinder: ignore */ +namespace { - size_t nbytes = fread(buff, 1, STATUS_SIZE-1, status_filep); - buff[nbytes] = '\0'; + U32 readFromProcStat( std::string entryName ) + { + U32 val{}; +#if LL_LINUX + constexpr U32 STATUS_SIZE = 2048; - // All these guys return numbers in KB - char *memp = strstr(buff, "VmSize:"); - if (memp) + LLFILE* status_filep = LLFile::fopen("/proc/self/status", "rb"); + if (status_filep) { - numRead += sscanf(memp, "%*s %u", &virtual_size); + char buff[STATUS_SIZE]; /* Flawfinder: ignore */ + + size_t nbytes = fread(buff, 1, STATUS_SIZE-1, status_filep); + buff[nbytes] = '\0'; + + // All these guys return numbers in KB + char *memp = strstr(buff, entryName.c_str()); + if (memp) + { + (void) sscanf(memp, "%*s %u", &val); + } + fclose(status_filep); } - fclose(status_filep); - } #endif - return virtual_size; + return val; + } + } //static -U32 LLOSInfo::getProcessResidentSizeKB() +U32 LLOSInfo::getProcessVirtualSizeKB() { - U32 resident_size = 0; -#if LL_LINUX - LLFILE* status_filep = LLFile::fopen("/proc/self/status", "rb"); - if (status_filep != NULL) - { - S32 numRead = 0; - char buff[STATUS_SIZE]; /* Flawfinder: ignore */ - - size_t nbytes = fread(buff, 1, STATUS_SIZE-1, status_filep); - buff[nbytes] = '\0'; + return readFromProcStat( "VmSize:" ); +} - // All these guys return numbers in KB - char *memp = strstr(buff, "VmRSS:"); - if (memp) - { - numRead += sscanf(memp, "%*s %u", &resident_size); - } - fclose(status_filep); - } -#endif - return resident_size; +//static +U32 LLOSInfo::getProcessResidentSizeKB() +{ + return readFromProcStat( "VmRSS:" ); } //static |