summaryrefslogtreecommitdiff
path: root/indra/llcommon/llmemory.cpp
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-08-18 22:30:27 -0700
committerRichard Linden <none@none>2013-08-18 22:30:27 -0700
commit612892b45a3413b16e40c49d3bfde77a4ca927fd (patch)
tree2272a24c7f0a8354791f74c7485a376abb377f67 /indra/llcommon/llmemory.cpp
parentf8e3a34348ab98ecd56d53360b8f2b6512ad6bba (diff)
SH-4433 WIP: Interesting: Statistics > Ping Sim is always 0 ms
continued conversion to units system made units perform type promotion correctly and preserve type in arithmetic e.g. can now do LLVector3 in units added typedefs for remaining common unit types, including implicits
Diffstat (limited to 'indra/llcommon/llmemory.cpp')
-rwxr-xr-xindra/llcommon/llmemory.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index c59b61471a..d46e205500 100755
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -47,11 +47,11 @@
//static
char* LLMemory::reserveMem = 0;
-U32Kibibytes LLMemory::sAvailPhysicalMemInKB(U32_MAX);
-U32Kibibytes LLMemory::sMaxPhysicalMemInKB(0);
-U32Kibibytes LLMemory::sAllocatedMemInKB(0);
-U32Kibibytes LLMemory::sAllocatedPageSizeInKB(0);
-U32Kibibytes LLMemory::sMaxHeapSizeInKB(U32_MAX);
+U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX);
+U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0);
+U32Kilobytes LLMemory::sAllocatedMemInKB(0);
+U32Kilobytes LLMemory::sAllocatedPageSizeInKB(0);
+U32Kilobytes LLMemory::sMaxHeapSizeInKB(U32_MAX);
BOOL LLMemory::sEnableMemoryFailurePrevention = FALSE;
#if __DEBUG_PRIVATE_MEM__
@@ -94,9 +94,9 @@ void LLMemory::freeReserve()
}
//static
-void LLMemory::initMaxHeapSizeGB(F32 max_heap_size_gb, BOOL prevent_heap_failure)
+void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure)
{
- sMaxHeapSizeInKB = (U32)(max_heap_size_gb * 1024 * 1024) ;
+ sMaxHeapSizeInKB = max_heap_size;
sEnableMemoryFailurePrevention = prevent_heap_failure ;
}
@@ -113,10 +113,10 @@ void LLMemory::updateMemoryInfo()
return ;
}
- sAllocatedMemInKB = (U32)(counters.WorkingSetSize / 1024) ;
- sAllocatedPageSizeInKB = (U32)(counters.PagefileUsage / 1024) ;
+ sAllocatedMemInKB = (U32Bytes)(counters.WorkingSetSize) ;
+ sAllocatedPageSizeInKB = (U32Bytes)(counters.PagefileUsage) ;
- U32Kibibytes avail_phys, avail_virtual;
+ U32Kilobytes avail_phys, avail_virtual;
LLMemoryInfo::getAvailableMemoryKB(avail_phys, avail_virtual) ;
sMaxPhysicalMemInKB = llmin(avail_phys + sAllocatedMemInKB, sMaxHeapSizeInKB);
@@ -126,7 +126,7 @@ void LLMemory::updateMemoryInfo()
}
else
{
- sAvailPhysicalMemInKB = 0 ;
+ sAvailPhysicalMemInKB = U32Kilobytes(0);
}
#else
//not valid for other systems for now.
@@ -187,8 +187,8 @@ void LLMemory::logMemoryInfo(BOOL update)
//static
bool LLMemory::isMemoryPoolLow()
{
- static const U32 LOW_MEMEOY_POOL_THRESHOLD_KB = 64 * 1024 ; //64 MB for emergency use
- const static U32 MAX_SIZE_CHECKED_MEMORY_BLOCK = 64 * 1024 * 1024 ; //64 MB
+ 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)
@@ -196,32 +196,32 @@ bool LLMemory::isMemoryPoolLow()
return false ; //no memory failure prevention.
}
- if(sAvailPhysicalMemInKB < (LOW_MEMEOY_POOL_THRESHOLD_KB >> 2)) //out of physical memory
+ if(sAvailPhysicalMemInKB < (LOW_MEMORY_POOL_THRESHOLD / 4)) //out of physical memory
{
return true ;
}
- if(sAllocatedPageSizeInKB + (LOW_MEMEOY_POOL_THRESHOLD_KB >> 2) > sMaxHeapSizeInKB) //out of virtual address space.
+ if(sAllocatedPageSizeInKB + (LOW_MEMORY_POOL_THRESHOLD / 4) > sMaxHeapSizeInKB) //out of virtual address space.
{
return true ;
}
- bool is_low = (S32)(sAvailPhysicalMemInKB < LOW_MEMEOY_POOL_THRESHOLD_KB ||
- sAllocatedPageSizeInKB + LOW_MEMEOY_POOL_THRESHOLD_KB > sMaxHeapSizeInKB) ;
+ 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) ;
+ 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) ;
+ 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) ;
+ last_reserved_address = LLMemory::tryToAlloc(last_reserved_address, MAX_SIZE_CHECKED_MEMORY_BLOCK.value()) ;
}
}
@@ -232,19 +232,19 @@ bool LLMemory::isMemoryPoolLow()
}
//static
-U32Kibibytes LLMemory::getAvailableMemKB()
+U32Kilobytes LLMemory::getAvailableMemKB()
{
return sAvailPhysicalMemInKB ;
}
//static
-U32Kibibytes LLMemory::getMaxMemKB()
+U32Kilobytes LLMemory::getMaxMemKB()
{
return sMaxPhysicalMemInKB ;
}
//static
-U32Kibibytes LLMemory::getAllocatedMemKB()
+U32Kilobytes LLMemory::getAllocatedMemKB()
{
return sAllocatedMemInKB ;
}