Memory consumption in statistics floater

This commit is contained in:
Siana Gearz
2012-03-01 13:49:47 +01:00
parent ab26e1008f
commit 251b0fa5c0
5 changed files with 84 additions and 6 deletions

View File

@@ -105,9 +105,9 @@ void LLFloaterStats::buildStats()
stat_barp = stat_viewp->addStat("Allocated memory", &(LLViewerStats::getInstance()->mMallocStat), "DebugStatModeMalloc");
stat_barp->setUnitLabel(" MB");
stat_barp->mMinBar = 0.f;
stat_barp->mMaxBar = 4000.f;
stat_barp->mTickSpacing = 100.f;
stat_barp->mLabelSpacing = 200.f;
stat_barp->mMaxBar = 2048.f;
stat_barp->mTickSpacing = 128.f;
stat_barp->mLabelSpacing = 512.f;
stat_barp->mPerSec = FALSE;
stat_barp->mDisplayMean = FALSE;
}

View File

@@ -83,6 +83,7 @@
#include "llwlparammanager.h"
#include "llwaterparammanager.h"
#include "llpostprocess.h"
#include "sgmemstat.h"
// [RLVa:KB]
#include "rlvhandler.h"
@@ -229,6 +230,7 @@ void display_stats()
U32 memory = (U32)(gMemoryAllocated / (1024*1024));
llinfos << llformat("MEMORY: %d MB", memory) << llendl;
llinfos << "THREADS: "<< LLThread::getCount() << llendl;
llinfos << "MALLOC: " << SGMemStat::getPrintableStat() <<llendl;
LLMemory::logMemoryInfo(TRUE) ;
gRecentMemoryTime.reset();
}

View File

@@ -61,6 +61,7 @@
#include "llfeaturemanager.h"
#include "llviewernetwork.h"
#include "llmeshrepository.h" //for LLMeshRepository::sBytesReceived
#include "sgmemstat.h"
#if LL_LCD_COMPILE
#include "lllcd.h"
#endif
@@ -689,6 +690,17 @@ void update_statistics(U32 frame_count)
}
}
{
static const F32 mem_stats_freq = 10.f;
static LLFrameTimer mem_stats_timer;
if (mem_stats_timer.getElapsedTimeF32() >= mem_stats_freq)
{
LLViewerStats::getInstance()->mMallocStat.addValue(SGMemStat::getMalloc()/1024.f/1024.f);
mem_stats_timer.reset();
}
}
#if LL_LCD_COMPILE
bool LCDenabled = gLcdScreen->Enabled();
LLViewerStats::getInstance()->setStat(LLViewerStats::ST_LOGITECH_LCD, LCDenabled);

View File

@@ -18,14 +18,76 @@
#include "llviewerprecompiledheaders.h"
#include "sgmemstat.h"
#if 0
bool SGMemStat::haveStat() {
return false;
return false;
}
F32 SGMemStat::getMalloc() {
return 0.f;
return 0.f;
}
U32 SGMemStat::getNumObjects() {
return 0;
return 0;
}
std::string SGMemStat::getPrintableStat() {
return std::string();
}
#else
extern "C" {
typedef void (*MallocExtension_GetStats_t)(char* buffer, int buffer_length);
typedef int (*MallocExtension_GetNumericProperty_t)(const char* property, size_t* value);
//typedef int (*MallocExtension_SetNumericProperty_t)(const char* property, size_t value);
}
static MallocExtension_GetNumericProperty_t MallocExtension_GetNumericProperty = 0;
static MallocExtension_GetStats_t MallocExtension_GetStats = 0;
static void initialize() {
static bool initialized = false;
if (!initialized) {
apr_dso_handle_t* hprog;// = (apr_dso_handle_t*)dlopen(0,0);
LLAPRPool pool;
pool.create();
apr_dso_load(&hprog, 0, pool());
apr_dso_sym((apr_dso_handle_sym_t*)&MallocExtension_GetNumericProperty,
hprog, "MallocExtension_GetNumericProperty");
apr_dso_sym((apr_dso_handle_sym_t*)&MallocExtension_GetStats,
hprog, "MallocExtension_GetStats");
initialized = true;
}
}
bool SGMemStat::haveStat() {
initialize();
return MallocExtension_GetNumericProperty;
}
F32 SGMemStat::getMalloc() {
if(MallocExtension_GetNumericProperty) {
size_t value;
MallocExtension_GetNumericProperty("generic.current_allocated_bytes", &value);
return value;
}
else return 0.0f;
}
U32 SGMemStat::getNumObjects() {
return 0;
}
std::string SGMemStat::getPrintableStat() {
initialize();
if (MallocExtension_GetStats) {
char buffer[4096];
buffer[4095] = 0;
MallocExtension_GetStats(buffer, 4095);
return std::string(buffer);
}
else return std::string();
}
#endif

View File

@@ -26,6 +26,8 @@ F32 getMalloc();
U32 getNumObjects();
std::string getPrintableStat();
}
#endif