diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2017-05-02 10:51:18 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2017-05-02 10:51:18 -0400 |
commit | 52899ed62a241d7875277b0f3412e2be78f7b3af (patch) | |
tree | 15bbb3dc668add51502b5390b26d09357e33800b /indra/llcommon/llmemory.h | |
parent | cdbad842c276efda32b36aba1040e3205f0fc38c (diff) |
DRTVWR-418, MAINT-6996: Rationalize LLMemory wrt 64-bit support.
There were two distinct LLMemory methods getCurrentRSS() and
getWorkingSetSize(). It was pointless to have both: on Windows they were
completely redundant; on other platforms getWorkingSetSize() always returned
0. (Amusingly, though the Windows implementations both made exactly the same
GetProcessMemoryInfo() call and used exactly the same logic, the code was
different in the two -- as though the second was implemented without awareness
of the first, even though they were adjacent in the source file.)
One of the actual MAINT-6996 problems was due to the fact that
getWorkingSetSize() returned U32, where getCurrentRSS() returns U64. In other
words, getWorkingSetSize() was both useless *and* wrong. Remove it, and change
its one call to getCurrentRSS() instead.
The other culprit was that in several places, the 64-bit WorkingSetSize
returned by the Windows GetProcessMemoryInfo() call (and by getCurrentRSS())
was explicitly cast to a 32-bit data type. That works only when explicitly or
implicitly (using LLUnits type conversion) scaling the value to kilobytes or
megabytes. When the size in bytes is desired, use 64-bit types instead.
In addition to the symptoms, LLMemory was overdue for a bit of cleanup.
There was a 16K block of memory called reserveMem, the comment on which read:
"reserve 16K for out of memory error handling." Yet *nothing* was ever done
with that block! If it were going to be useful, one would think someone would
at some point explicitly free the block. In fact there was a method
freeReserve(), apparently for just that purpose -- which was never called. As
things stood, reserveMem served only to *prevent* the viewer from ever using
that chunk of memory. Remove reserveMem and the unused freeReserve().
The only function of initClass() and cleanupClass() was to allocate and free
reserveMem. Remove initClass(), cleanupClass() and the LLCommon calls to them.
In a similar vein, there was an LLMemoryInfo::getPhysicalMemoryClamped()
method that returned U32Bytes. Its job was simply to return a size in bytes
that could fit into a U32 data type, returning U32_MAX if the 64-bit value
exceeded 4GB. Eliminate that; change all its calls to getPhysicalMemoryKB()
(which getPhysicalMemoryClamped() used internally anyway). We no longer care
about any platform that cannot handle 64-bit data types.
Diffstat (limited to 'indra/llcommon/llmemory.h')
-rw-r--r-- | indra/llcommon/llmemory.h | 5 |
1 files changed, 0 insertions, 5 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 5a3c9bd762..c37967e10e 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -334,13 +334,9 @@ inline void ll_memcpy_nonaliased_aligned_16(char* __restrict dst, const char* __ class LL_COMMON_API LLMemory { public: - static void initClass(); - static void cleanupClass(); - static void freeReserve(); // Return the resident set size of the current process, in bytes. // Return value is zero if not known. static U64 getCurrentRSS(); - static U32 getWorkingSetSize(); static void* tryToAlloc(void* address, U32 size); static void initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure); static void updateMemoryInfo() ; @@ -351,7 +347,6 @@ public: static U32Kilobytes getMaxMemKB() ; static U32Kilobytes getAllocatedMemKB() ; private: - static char* reserveMem; static U32Kilobytes sAvailPhysicalMemInKB ; static U32Kilobytes sMaxPhysicalMemInKB ; static U32Kilobytes sAllocatedMemInKB; |