diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2011-01-26 17:03:30 -0700 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2011-01-26 17:03:30 -0700 |
commit | 6531eed04e24239233f79624572219e88017f476 (patch) | |
tree | b1ba1d38648046f2d2a42ae03ad84bdd55518b11 /indra | |
parent | 8f54dc2958e75587165623b0292940200fb49f59 (diff) |
add "pause" function for SH-846: design and implement the debug code to locate memory leaking
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llcommon/llmemory.cpp | 18 | ||||
-rw-r--r-- | indra/llcommon/llmemory.h | 3 | ||||
-rw-r--r-- | indra/newview/llmemoryview.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llmemoryview.h | 1 |
4 files changed, 19 insertions, 7 deletions
diff --git a/indra/llcommon/llmemory.cpp b/indra/llcommon/llmemory.cpp index e4ece78d53..f340105f57 100644 --- a/indra/llcommon/llmemory.cpp +++ b/indra/llcommon/llmemory.cpp @@ -275,6 +275,7 @@ LLMemTracker::LLMemTracker() mCurIndex = 0 ; mCounter = 0 ; mDrawnIndex = 0 ; + mPaused = FALSE ; mMutexp = new LLMutex(NULL) ; mStringBuffer = new char*[128] ; @@ -315,19 +316,25 @@ void LLMemTracker::release() //static void LLMemTracker::track(const char* function, const int line) { - static const S32 MIN_ALLOCATION = 1024 ; //1KB + static const S32 MIN_ALLOCATION = 0 ; //1KB + + if(mPaused) + { + return ; + } U32 allocated_mem = LLMemory::getWorkingSetSize() ; LLMutexLock lock(mMutexp) ; - if(allocated_mem <= mLastAllocatedMem) + S32 delta_mem = allocated_mem - mLastAllocatedMem ; + mLastAllocatedMem = allocated_mem ; + + if(delta_mem <= 0) { return ; //occupied memory does not grow } - S32 delta_mem = allocated_mem - mLastAllocatedMem ; - mLastAllocatedMem = allocated_mem ; if(delta_mem < MIN_ALLOCATION) { return ; @@ -353,10 +360,11 @@ void LLMemTracker::track(const char* function, const int line) //static -void LLMemTracker::preDraw() +void LLMemTracker::preDraw(BOOL pause) { mMutexp->lock() ; + mPaused = pause ; mDrawnIndex = mCurIndex - 1; mNumOfDrawn = 0 ; } diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index e6a6a8c3da..11406f59b0 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -63,7 +63,7 @@ public: static LLMemTracker* getInstance() ; void track(const char* function, const int line) ; - void preDraw() ; + void preDraw(BOOL pause) ; void postDraw() ; const char* getNextLine() ; @@ -77,6 +77,7 @@ private: S32 mCounter; S32 mDrawnIndex; S32 mNumOfDrawn; + BOOL mPaused; LLMutex* mMutexp ; }; diff --git a/indra/newview/llmemoryview.cpp b/indra/newview/llmemoryview.cpp index 397a77c4e3..7e9c3c84a7 100644 --- a/indra/newview/llmemoryview.cpp +++ b/indra/newview/llmemoryview.cpp @@ -41,6 +41,7 @@ LLMemoryView::LLMemoryView(const LLMemoryView::Params& p) : LLView(p), + mPaused(FALSE), //mDelay(120), mAlloc(NULL) { @@ -60,6 +61,7 @@ BOOL LLMemoryView::handleMouseDown(S32 x, S32 y, MASK mask) } else { + mPaused = !mPaused; } return TRUE; } @@ -172,7 +174,7 @@ void LLMemoryView::draw() } #else - LLMemTracker::getInstance()->preDraw() ; + LLMemTracker::getInstance()->preDraw(mPaused) ; { F32 x_pos = MARGIN_AMT ; diff --git a/indra/newview/llmemoryview.h b/indra/newview/llmemoryview.h index 24ea058279..9bdc59ab10 100644 --- a/indra/newview/llmemoryview.h +++ b/indra/newview/llmemoryview.h @@ -55,6 +55,7 @@ public: private: std::vector<LLWString> mLines; LLAllocator* mAlloc; + BOOL mPaused ; }; |