for SH-335: create a debug tool to track of memory availability.
parent
dedc78431f
commit
5ee546eb4e
|
|
@ -635,6 +635,25 @@ U32 LLMemoryInfo::getPhysicalMemoryClamped() const
|
|||
}
|
||||
}
|
||||
|
||||
void LLMemoryInfo::getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb) const
|
||||
{
|
||||
#if LL_WINDOWS
|
||||
MEMORYSTATUSEX state;
|
||||
state.dwLength = sizeof(state);
|
||||
GlobalMemoryStatusEx(&state);
|
||||
|
||||
avail_physical_mem_kb = (U32)(state.ullAvailPhys/1024) ;
|
||||
avail_virtual_mem_kb = (U32)(state.ullAvailVirtual/1024) ;
|
||||
|
||||
#else
|
||||
//do not know how to collect available memory info for other systems.
|
||||
//leave it blank here for now.
|
||||
|
||||
avail_physical_mem_kb = -1 ;
|
||||
avail_virtual_mem_kb = -1 ;
|
||||
#endif
|
||||
}
|
||||
|
||||
void LLMemoryInfo::stream(std::ostream& s) const
|
||||
{
|
||||
#if LL_WINDOWS
|
||||
|
|
|
|||
|
|
@ -114,6 +114,9 @@ public:
|
|||
** be returned.
|
||||
*/
|
||||
U32 getPhysicalMemoryClamped() const; ///< Memory size in clamped bytes
|
||||
|
||||
//get the available memory infomation in KiloBytes.
|
||||
void getAvailableMemoryKB(U32& avail_physical_mem_kb, U32& avail_virtual_mem_kb) const;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -984,6 +984,7 @@ bool LLAppViewer::mainLoop()
|
|||
LLVoiceClient::getInstance()->init(gServicePump);
|
||||
LLTimer frameTimer,idleTimer;
|
||||
LLTimer debugTime;
|
||||
LLFrameTimer memCheckTimer;
|
||||
LLViewerJoystick* joystick(LLViewerJoystick::getInstance());
|
||||
joystick->setNeedsReset(true);
|
||||
|
||||
|
|
@ -994,11 +995,29 @@ bool LLAppViewer::mainLoop()
|
|||
// point of posting.
|
||||
LLSD newFrame;
|
||||
|
||||
const F32 memory_check_interval = 1.0f ; //second
|
||||
|
||||
// Handle messages
|
||||
while (!LLApp::isExiting())
|
||||
{
|
||||
LLFastTimer::nextFrame(); // Should be outside of any timer instances
|
||||
|
||||
//clear call stack records
|
||||
llclearcallstacks;
|
||||
|
||||
//check memory availability information
|
||||
{
|
||||
if(memory_check_interval < memCheckTimer.getElapsedTimeF32())
|
||||
{
|
||||
memCheckTimer.reset() ;
|
||||
|
||||
//update the availability of memory
|
||||
gSysMemory.getAvailableMemoryKB(mAvailPhysicalMemInKB, mAvailVirtualMemInKB) ;
|
||||
}
|
||||
llcallstacks << "Available physical mem(KB): " << mAvailPhysicalMemInKB << llcallstacksendl ;
|
||||
llcallstacks << "Available virtual mem(KB): " << mAvailVirtualMemInKB << llcallstacksendl ;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
pingMainloopTimeout("Main:MiscNativeWindowEvents");
|
||||
|
|
@ -1225,11 +1244,20 @@ bool LLAppViewer::mainLoop()
|
|||
resumeMainloopTimeout();
|
||||
|
||||
pingMainloopTimeout("Main:End");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch(std::bad_alloc)
|
||||
{
|
||||
{
|
||||
llinfos << "Availabe physical memory(KB) at the beginning of the frame: " << mAvailPhysicalMemInKB << llendl ;
|
||||
llinfos << "Availabe virtual memory(KB) at the beginning of the frame: " << mAvailVirtualMemInKB << llendl ;
|
||||
|
||||
gSysMemory.getAvailableMemoryKB(mAvailPhysicalMemInKB, mAvailVirtualMemInKB) ;
|
||||
|
||||
llinfos << "Current availabe physical memory(KB): " << mAvailPhysicalMemInKB << llendl ;
|
||||
llinfos << "Current availabe virtual memory(KB): " << mAvailVirtualMemInKB << llendl ;
|
||||
}
|
||||
|
||||
//stop memory leaking simulation
|
||||
LLFloaterMemLeak* mem_leak_instance =
|
||||
LLFloaterReg::findTypedInstance<LLFloaterMemLeak>("mem_leaking");
|
||||
|
|
|
|||
|
|
@ -258,6 +258,8 @@ private:
|
|||
|
||||
std::set<struct apr_dso_handle_t*> mPlugins;
|
||||
|
||||
U32 mAvailPhysicalMemInKB ;
|
||||
U32 mAvailVirtualMemInKB ;
|
||||
public:
|
||||
//some information for updater
|
||||
typedef struct
|
||||
|
|
|
|||
|
|
@ -706,7 +706,6 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot)
|
|||
//
|
||||
// Doing this here gives hardware occlusion queries extra time to complete
|
||||
LLAppViewer::instance()->pingMainloopTimeout("Display:UpdateImages");
|
||||
LLError::LLCallStacks::clear() ;
|
||||
|
||||
{
|
||||
LLMemType mt_iu(LLMemType::MTYPE_DISPLAY_IMAGE_UPDATE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue