summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llcommon/llcommon.cpp2
-rw-r--r--indra/llcommon/llmemory.cpp108
-rw-r--r--indra/llcommon/llmemory.h5
-rw-r--r--indra/llcommon/llsys.cpp16
-rw-r--r--indra/llcommon/llsys.h5
-rw-r--r--indra/newview/llappviewer.cpp9
-rw-r--r--indra/newview/llfeaturemanager.cpp2
-rw-r--r--indra/newview/llviewerdisplay.cpp4
-rw-r--r--indra/newview/llviewertexturelist.cpp8
-rw-r--r--indra/newview/llviewerwindow.cpp4
10 files changed, 32 insertions, 131 deletions
diff --git a/indra/llcommon/llcommon.cpp b/indra/llcommon/llcommon.cpp
index 439ff4e628..2d665c611b 100644
--- a/indra/llcommon/llcommon.cpp
+++ b/indra/llcommon/llcommon.cpp
@@ -41,7 +41,6 @@ static LLTrace::ThreadRecorder* sMasterThreadRecorder = NULL;
//static
void LLCommon::initClass()
{
- LLMemory::initClass();
if (!sAprInitialized)
{
ll_init_apr();
@@ -70,5 +69,4 @@ void LLCommon::cleanupClass()
ll_cleanup_apr();
sAprInitialized = FALSE;
}
- SUBSYSTEM_CLEANUP(LLMemory);
}
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp
index 1e04044269..9f9c3af892 100644
--- a/indra/llcommon/llmemory.cpp
+++ b/indra/llcommon/llmemory.cpp
@@ -44,10 +44,10 @@
#include "llsys.h"
#include "llframetimer.h"
#include "lltrace.h"
+#include "llerror.h"
//----------------------------------------------------------------------------
//static
-char* LLMemory::reserveMem = 0;
U32Kilobytes LLMemory::sAvailPhysicalMemInKB(U32_MAX);
U32Kilobytes LLMemory::sMaxPhysicalMemInKB(0);
static LLTrace::SampleStatHandle<F64Megabytes> sAllocatedMem("allocated_mem", "active memory in use by application");
@@ -78,29 +78,6 @@ void ll_assert_aligned_func(uintptr_t ptr,U32 alignment)
#endif
}
-//static
-void LLMemory::initClass()
-{
- if (!reserveMem)
- {
- reserveMem = new char[16*1024]; // reserve 16K for out of memory error handling
- }
-}
-
-//static
-void LLMemory::cleanupClass()
-{
- delete [] reserveMem;
- reserveMem = NULL;
-}
-
-//static
-void LLMemory::freeReserve()
-{
- delete [] reserveMem;
- reserveMem = NULL;
-}
-
//static
void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_failure)
{
@@ -111,19 +88,18 @@ void LLMemory::initMaxHeapSizeGB(F32Gigabytes max_heap_size, BOOL prevent_heap_f
//static
void LLMemory::updateMemoryInfo()
{
-#if LL_WINDOWS
- HANDLE self = GetCurrentProcess();
+#if LL_WINDOWS
PROCESS_MEMORY_COUNTERS counters;
-
- if (!GetProcessMemoryInfo(self, &counters, sizeof(counters)))
+
+ if (!GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)))
{
LL_WARNS() << "GetProcessMemoryInfo failed" << LL_ENDL;
return ;
}
- sAllocatedMemInKB = (U32Bytes)(counters.WorkingSetSize) ;
+ sAllocatedMemInKB = U64Bytes(counters.WorkingSetSize) ;
sample(sAllocatedMem, sAllocatedMemInKB);
- sAllocatedPageSizeInKB = (U32Bytes)(counters.PagefileUsage) ;
+ sAllocatedPageSizeInKB = U64Bytes(counters.PagefileUsage) ;
sample(sVirtualMem, sAllocatedPageSizeInKB);
U32Kilobytes avail_phys, avail_virtual;
@@ -140,9 +116,9 @@ void LLMemory::updateMemoryInfo()
}
#else
//not valid for other systems for now.
- sAllocatedMemInKB = (U32Bytes)LLMemory::getCurrentRSS();
- sMaxPhysicalMemInKB = (U32Bytes)U32_MAX ;
- sAvailPhysicalMemInKB = (U32Bytes)U32_MAX ;
+ sAllocatedMemInKB = U64Bytes(LLMemory::getCurrentRSS());
+ sMaxPhysicalMemInKB = U64Bytes(U32_MAX);
+ sAvailPhysicalMemInKB = U64Bytes(U32_MAX);
#endif
return ;
@@ -169,7 +145,7 @@ void* LLMemory::tryToAlloc(void* address, U32 size)
return address ;
#else
return (void*)0x01 ; //skip checking
-#endif
+#endif
}
//static
@@ -183,7 +159,7 @@ void LLMemory::logMemoryInfo(BOOL update)
LL_INFOS() << "Current allocated physical memory(KB): " << sAllocatedMemInKB << LL_ENDL ;
LL_INFOS() << "Current allocated page size (KB): " << sAllocatedPageSizeInKB << LL_ENDL ;
- LL_INFOS() << "Current availabe physical memory(KB): " << sAvailPhysicalMemInKB << LL_ENDL ;
+ LL_INFOS() << "Current available physical memory(KB): " << sAvailPhysicalMemInKB << LL_ENDL ;
LL_INFOS() << "Current max usable memory(KB): " << sMaxPhysicalMemInKB << LL_ENDL ;
LL_INFOS() << "--- private pool information -- " << LL_ENDL ;
@@ -263,12 +239,12 @@ U32Kilobytes LLMemory::getAllocatedMemKB()
#if defined(LL_WINDOWS)
+//static
U64 LLMemory::getCurrentRSS()
{
- HANDLE self = GetCurrentProcess();
PROCESS_MEMORY_COUNTERS counters;
-
- if (!GetProcessMemoryInfo(self, &counters, sizeof(counters)))
+
+ if (!GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters)))
{
LL_WARNS() << "GetProcessMemoryInfo failed" << LL_ENDL;
return 0;
@@ -277,35 +253,8 @@ U64 LLMemory::getCurrentRSS()
return counters.WorkingSetSize;
}
-//static
-U32 LLMemory::getWorkingSetSize()
-{
- PROCESS_MEMORY_COUNTERS pmc ;
- U32 ret = 0 ;
-
- if (GetProcessMemoryInfo( GetCurrentProcess(), &pmc, sizeof(pmc)) )
- {
- ret = pmc.WorkingSetSize ;
- }
-
- return ret ;
-}
-
#elif defined(LL_DARWIN)
-/*
- The API used here is not capable of dealing with 64-bit memory sizes, but is available before 10.4.
-
- Once we start requiring 10.4, we can use the updated API, which looks like this:
-
- task_basic_info_64_data_t basicInfo;
- mach_msg_type_number_t basicInfoCount = TASK_BASIC_INFO_64_COUNT;
- if (task_info(mach_task_self(), TASK_BASIC_INFO_64, (task_info_t)&basicInfo, &basicInfoCount) == KERN_SUCCESS)
-
- Of course, this doesn't gain us anything unless we start building the viewer as a 64-bit executable, since that's the only way
- for our memory allocation to exceed 2^32.
-*/
-
// if (sysctl(ctl, 2, &page_size, &size, NULL, 0) == -1)
// {
// LL_WARNS() << "Couldn't get page size" << LL_ENDL;
@@ -318,9 +267,9 @@ U32 LLMemory::getWorkingSetSize()
U64 LLMemory::getCurrentRSS()
{
U64 residentSize = 0;
- task_basic_info_data_t basicInfo;
- mach_msg_type_number_t basicInfoCount = TASK_BASIC_INFO_COUNT;
- if (task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&basicInfo, &basicInfoCount) == KERN_SUCCESS)
+ task_basic_info_64_data_t basicInfo;
+ mach_msg_type_number_t basicInfoCount = TASK_BASIC_INFO_64_COUNT;
+ if (task_info(mach_task_self(), TASK_BASIC_INFO_64, (task_info_t)&basicInfo, &basicInfoCount) == KERN_SUCCESS)
{
residentSize = basicInfo.resident_size;
@@ -337,11 +286,6 @@ U64 LLMemory::getCurrentRSS()
return residentSize;
}
-U32 LLMemory::getWorkingSetSize()
-{
- return 0 ;
-}
-
#elif defined(LL_LINUX)
U64 LLMemory::getCurrentRSS()
@@ -353,7 +297,7 @@ U64 LLMemory::getCurrentRSS()
if (fp == NULL)
{
LL_WARNS() << "couldn't open " << statPath << LL_ENDL;
- goto bail;
+ return 0;
}
// Eee-yew! See Documentation/filesystems/proc.txt in your
@@ -372,15 +316,9 @@ U64 LLMemory::getCurrentRSS()
fclose(fp);
-bail:
return rss;
}
-U32 LLMemory::getWorkingSetSize()
-{
- return 0 ;
-}
-
#elif LL_SOLARIS
#include <sys/types.h>
#include <sys/stat.h>
@@ -410,11 +348,6 @@ U64 LLMemory::getCurrentRSS()
return((U64)proc_psinfo.pr_rssize * 1024);
}
-U32 LLMemory::getWorkingSetSize()
-{
- return 0 ;
-}
-
#else
U64 LLMemory::getCurrentRSS()
@@ -422,11 +355,6 @@ U64 LLMemory::getCurrentRSS()
return 0;
}
-U32 LLMemory::getWorkingSetSize()
-{
- return 0;
-}
-
#endif
//--------------------------------------------------------------------------------------------------
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;
diff --git a/indra/llcommon/llsys.cpp b/indra/llcommon/llsys.cpp
index 1a66612e87..265c637b69 100644
--- a/indra/llcommon/llsys.cpp
+++ b/indra/llcommon/llsys.cpp
@@ -914,22 +914,6 @@ U32Kilobytes LLMemoryInfo::getPhysicalMemoryKB() const
#endif
}
-U32Bytes LLMemoryInfo::getPhysicalMemoryClamped() const
-{
- // Return the total physical memory in bytes, but clamp it
- // to no more than U32_MAX
-
- U32Kilobytes phys_kb = getPhysicalMemoryKB();
- if (phys_kb >= U32Gigabytes(4))
- {
- return U32Bytes(U32_MAX);
- }
- else
- {
- return phys_kb;
- }
-}
-
//static
void LLMemoryInfo::getAvailableMemoryKB(U32Kilobytes& avail_physical_mem_kb, U32Kilobytes& avail_virtual_mem_kb)
{
diff --git a/indra/llcommon/llsys.h b/indra/llcommon/llsys.h
index 962367f69f..95ef4cf065 100644
--- a/indra/llcommon/llsys.h
+++ b/indra/llcommon/llsys.h
@@ -113,11 +113,6 @@ public:
void stream(std::ostream& s) const; ///< output text info to s
U32Kilobytes getPhysicalMemoryKB() const;
-
- /*! Memory size in bytes, if total memory is >= 4GB then U32_MAX will
- ** be returned.
- */
- U32Bytes getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes
//get the available memory infomation in KiloBytes.
static void getAvailableMemoryKB(U32Kilobytes& avail_physical_mem_kb, U32Kilobytes& avail_virtual_mem_kb);
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index ae4e3df70f..d41f33700f 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1099,7 +1099,7 @@ bool LLAppViewer::init()
minSpecs += "\n";
unsupported = true;
}
- if(gSysMemory.getPhysicalMemoryClamped() < minRAM)
+ if(gSysMemory.getPhysicalMemoryKB() < minRAM)
{
minSpecs += LLNotifications::instance().getGlobalString("UnsupportedRAM");
minSpecs += "\n";
@@ -3743,11 +3743,10 @@ void LLAppViewer::handleViewerCrash()
{
gDebugInfo["Dynamic"]["ParcelMediaURL"] = parcel->getMediaURL();
}
-
-
+
gDebugInfo["Dynamic"]["SessionLength"] = F32(LLFrameTimer::getElapsedSeconds());
- gDebugInfo["Dynamic"]["RAMInfo"]["Allocated"] = (LLSD::Integer) LLMemory::getCurrentRSS() >> 10;
-
+ gDebugInfo["Dynamic"]["RAMInfo"]["Allocated"] = LLSD::Integer(LLMemory::getCurrentRSS() / 1024);
+
if(gLogoutInProgress)
{
gDebugInfo["Dynamic"]["LastExecEvent"] = LAST_EXEC_LOGOUT_CRASH;
diff --git a/indra/newview/llfeaturemanager.cpp b/indra/newview/llfeaturemanager.cpp
index d4ba230feb..ad048f6668 100644
--- a/indra/newview/llfeaturemanager.cpp
+++ b/indra/newview/llfeaturemanager.cpp
@@ -789,7 +789,7 @@ void LLFeatureManager::applyBaseMasks()
maskFeatures(gpustr);
// now mask cpu type ones
- if (gSysMemory.getPhysicalMemoryClamped() <= U32Megabytes(256))
+ if (gSysMemory.getPhysicalMemoryKB() <= U32Megabytes(256))
{
maskFeatures("RAM256MB");
}
diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp
index 13eccaefc1..960a36a251 100644
--- a/indra/newview/llviewerdisplay.cpp
+++ b/indra/newview/llviewerdisplay.cpp
@@ -220,9 +220,9 @@ void display_stats()
F32 mem_log_freq = gSavedSettings.getF32("MemoryLogFrequency");
if (mem_log_freq > 0.f && gRecentMemoryTime.getElapsedTimeF32() >= mem_log_freq)
{
- gMemoryAllocated = (U64Bytes)LLMemory::getCurrentRSS();
+ gMemoryAllocated = U64Bytes(LLMemory::getCurrentRSS());
U32Megabytes memory = gMemoryAllocated;
- LL_INFOS() << llformat("MEMORY: %d MB", memory.value()) << LL_ENDL;
+ LL_INFOS() << "MEMORY: " << memory << LL_ENDL;
LLMemory::logMemoryInfo(TRUE) ;
gRecentMemoryTime.reset();
}
diff --git a/indra/newview/llviewertexturelist.cpp b/indra/newview/llviewertexturelist.cpp
index d7080051da..0a3012ffef 100644
--- a/indra/newview/llviewertexturelist.cpp
+++ b/indra/newview/llviewertexturelist.cpp
@@ -1341,9 +1341,9 @@ LLPointer<LLImageJ2C> LLViewerTextureList::convertToUploadFile(LLPointer<LLImage
// Returns min setting for TextureMemory (in MB)
S32Megabytes LLViewerTextureList::getMinVideoRamSetting()
{
- S32Megabytes system_ram = gSysMemory.getPhysicalMemoryClamped();
+ U32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB();
//min texture mem sets to 64M if total physical mem is more than 1.5GB
- return (system_ram > S32Megabytes(1500)) ? S32Megabytes(64) : gMinVideoRam ;
+ return (system_ram > U32Megabytes(1500)) ? S32Megabytes(64) : gMinVideoRam ;
}
//static
@@ -1386,7 +1386,7 @@ S32Megabytes LLViewerTextureList::getMaxVideoRamSetting(bool get_recommended, fl
LL_WARNS() << "VRAM amount not detected, defaulting to " << max_texmem << " MB" << LL_ENDL;
}
- S32Megabytes system_ram = gSysMemory.getPhysicalMemoryClamped(); // In MB
+ S32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB(); // In MB
//LL_INFOS() << "*** DETECTED " << system_ram << " MB of system memory." << LL_ENDL;
if (get_recommended)
max_texmem = llmin(max_texmem, system_ram/2);
@@ -1439,7 +1439,7 @@ void LLViewerTextureList::updateMaxResidentTexMem(S32Megabytes mem)
}
//system mem
- S32Megabytes system_ram = gSysMemory.getPhysicalMemoryClamped();
+ S32Megabytes system_ram = gSysMemory.getPhysicalMemoryKB();
//minimum memory reserved for non-texture use.
//if system_raw >= 1GB, reserve at least 512MB for non-texture use;
diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp
index efad739bd3..feed5ba43d 100644
--- a/indra/newview/llviewerwindow.cpp
+++ b/indra/newview/llviewerwindow.cpp
@@ -53,6 +53,7 @@
#include "llrender.h"
#include "llvoiceclient.h" // for push-to-talk button handling
+#include "stringize.h"
//
// TODO: Many of these includes are unnecessary. Remove them.
@@ -394,7 +395,8 @@ public:
#if LL_WINDOWS
if (gSavedSettings.getBOOL("DebugShowMemory"))
{
- addText(xpos, ypos, llformat("Memory: %d (KB)", LLMemory::getWorkingSetSize() / 1024));
+ addText(xpos, ypos,
+ STRINGIZE("Memory: " << (LLMemory::getCurrentRSS() / 1024) << " (KB)"));
ypos += y_inc;
}
#endif