Skip to content
Snippets Groups Projects
Commit 6531eed0 authored by Xiaohong Bao's avatar Xiaohong Bao
Browse files

add "pause" function for SH-846: design and implement the debug code to locate memory leaking

parent 8f54dc29
No related branches found
No related tags found
No related merge requests found
...@@ -275,6 +275,7 @@ LLMemTracker::LLMemTracker() ...@@ -275,6 +275,7 @@ LLMemTracker::LLMemTracker()
mCurIndex = 0 ; mCurIndex = 0 ;
mCounter = 0 ; mCounter = 0 ;
mDrawnIndex = 0 ; mDrawnIndex = 0 ;
mPaused = FALSE ;
mMutexp = new LLMutex(NULL) ; mMutexp = new LLMutex(NULL) ;
mStringBuffer = new char*[128] ; mStringBuffer = new char*[128] ;
...@@ -315,19 +316,25 @@ void LLMemTracker::release() ...@@ -315,19 +316,25 @@ void LLMemTracker::release()
//static //static
void LLMemTracker::track(const char* function, const int line) 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() ; U32 allocated_mem = LLMemory::getWorkingSetSize() ;
LLMutexLock lock(mMutexp) ; 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 return ; //occupied memory does not grow
} }
S32 delta_mem = allocated_mem - mLastAllocatedMem ;
mLastAllocatedMem = allocated_mem ;
if(delta_mem < MIN_ALLOCATION) if(delta_mem < MIN_ALLOCATION)
{ {
return ; return ;
...@@ -353,10 +360,11 @@ void LLMemTracker::track(const char* function, const int line) ...@@ -353,10 +360,11 @@ void LLMemTracker::track(const char* function, const int line)
//static //static
void LLMemTracker::preDraw() void LLMemTracker::preDraw(BOOL pause)
{ {
mMutexp->lock() ; mMutexp->lock() ;
mPaused = pause ;
mDrawnIndex = mCurIndex - 1; mDrawnIndex = mCurIndex - 1;
mNumOfDrawn = 0 ; mNumOfDrawn = 0 ;
} }
......
...@@ -63,7 +63,7 @@ class LL_COMMON_API LLMemTracker ...@@ -63,7 +63,7 @@ class LL_COMMON_API LLMemTracker
static LLMemTracker* getInstance() ; static LLMemTracker* getInstance() ;
void track(const char* function, const int line) ; void track(const char* function, const int line) ;
void preDraw() ; void preDraw(BOOL pause) ;
void postDraw() ; void postDraw() ;
const char* getNextLine() ; const char* getNextLine() ;
...@@ -77,6 +77,7 @@ class LL_COMMON_API LLMemTracker ...@@ -77,6 +77,7 @@ class LL_COMMON_API LLMemTracker
S32 mCounter; S32 mCounter;
S32 mDrawnIndex; S32 mDrawnIndex;
S32 mNumOfDrawn; S32 mNumOfDrawn;
BOOL mPaused;
LLMutex* mMutexp ; LLMutex* mMutexp ;
}; };
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
LLMemoryView::LLMemoryView(const LLMemoryView::Params& p) LLMemoryView::LLMemoryView(const LLMemoryView::Params& p)
: LLView(p), : LLView(p),
mPaused(FALSE),
//mDelay(120), //mDelay(120),
mAlloc(NULL) mAlloc(NULL)
{ {
...@@ -60,6 +61,7 @@ BOOL LLMemoryView::handleMouseDown(S32 x, S32 y, MASK mask) ...@@ -60,6 +61,7 @@ BOOL LLMemoryView::handleMouseDown(S32 x, S32 y, MASK mask)
} }
else else
{ {
mPaused = !mPaused;
} }
return TRUE; return TRUE;
} }
...@@ -172,7 +174,7 @@ void LLMemoryView::draw() ...@@ -172,7 +174,7 @@ void LLMemoryView::draw()
} }
#else #else
LLMemTracker::getInstance()->preDraw() ; LLMemTracker::getInstance()->preDraw(mPaused) ;
{ {
F32 x_pos = MARGIN_AMT ; F32 x_pos = MARGIN_AMT ;
......
...@@ -55,6 +55,7 @@ class LLMemoryView : public LLView ...@@ -55,6 +55,7 @@ class LLMemoryView : public LLView
private: private:
std::vector<LLWString> mLines; std::vector<LLWString> mLines;
LLAllocator* mAlloc; LLAllocator* mAlloc;
BOOL mPaused ;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment