summaryrefslogtreecommitdiff
path: root/indra/llcommon/llmemory.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llmemory.cpp')
-rw-r--r--indra/llcommon/llmemory.cpp54
1 files changed, 1 insertions, 53 deletions
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 7cf4bc0706..ea84e4c1ea 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -55,7 +55,6 @@ static LLTrace::SampleStatHandle<F64Megabytes> sVirtualMem("virtual_mem", "virtu
U32Kilobytes LLMemory::sAllocatedMemInKB(0);
U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0);
U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX);
-BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
void ll_assert_aligned_func(uintptr_t ptr,U32 alignment)
{
@@ -75,10 +74,9 @@ void ll_assert_aligned_func(uintptr_t ptr,U32 alignment)
}
//static
-void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure)
+void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size)
{
sMaxHeapSizeInKB = U32Kilobytes::convert(max_heap_size);
- sEnableMemoryFailurePrevention = prevent_heap_failure ;
}
//static
@@ -158,56 +156,6 @@ void LLMemory::logMemoryInfo(BOOL update)
LL_INFOS() << "Current max usable memory(KB): " << sMaxPhysicalMemInKB << LL_ENDL ;
}
-//return 0: everything is normal;
-//return 1: the memory pool is low, but not in danger;
-//return -1: the memory pool is in danger, is about to crash.
-//static
-bool LLMemory::isMemoryPoolLow()
-{
- static const U32Megabytes LOW_MEMORY_POOL_THRESHOLD(64);
- const static U32Megabytes MAX_SIZE_CHECKED_MEMORY_BLOCK(64);
- static void* last_reserved_address = NULL ;
-
- if(!sEnableMemoryFailurePrevention)
- {
- return false ; //no memory failure prevention.
- }
-
- if(sAvailPhysicalMemInKB < (LOW_MEMORY_POOL_THRESHOLD / 4)) //out of physical memory
- {
- return true ;
- }
-
- if(sAllocatedPageSizeInKB + (LOW_MEMORY_POOL_THRESHOLD / 4) > sMaxHeapSizeInKB) //out of virtual address space.
- {
- return true ;
- }
-
- bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMORY_POOL_THRESHOLD
- || sAllocatedPageSizeInKB + LOW_MEMORY_POOL_THRESHOLD > sMaxHeapSizeInKB) ;
-
- //check the virtual address space fragmentation
- if(!is_low)
- {
- if(!last_reserved_address)
- {
- last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ;
- }
- else
- {
- last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ;
- if(!last_reserved_address) //failed, try once more
- {
- last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ;
- }
- }
-
- is_low = !last_reserved_address ; //allocation failed
- }
-
- return is_low ;
-}
-
//static
U32Kilobytes LLMemory::getAvailableMemKB()
{