diff options
author | Xiaohong Bao <bao@lindenlab.com> | 2011-02-23 10:44:59 -0700 |
---|---|---|
committer | Xiaohong Bao <bao@lindenlab.com> | 2011-02-23 10:44:59 -0700 |
commit | 01cdeb0cdd8c48b76a229d42ced4e5563cd18c5c (patch) | |
tree | e7b7ca976f17c8af3c8a2648a801030594e94c8c /indra/llcommon/llmemory.h | |
parent | 7daa3d1ca10199468946feef0ce8eb67489deee0 (diff) | |
parent | ff5e3f5c2e566f3a8e86efaa763f7b12e07eeb53 (diff) |
Merge from viewer-development
Diffstat (limited to 'indra/llcommon/llmemory.h')
-rw-r--r-- | indra/llcommon/llmemory.h | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/indra/llcommon/llmemory.h b/indra/llcommon/llmemory.h index 5a2889958b..4474df6f86 100644 --- a/indra/llcommon/llmemory.h +++ b/indra/llcommon/llmemory.h @@ -26,6 +26,7 @@ #ifndef LLMEMORY_H #define LLMEMORY_H +#include "llmemtype.h" extern S32 gTotalDAlloc; extern S32 gTotalDAUse; extern S32 gDACount; @@ -42,7 +43,7 @@ public: // 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(F32 max_heap_size_gb, BOOL prevent_heap_failure); static void updateMemoryInfo() ; @@ -63,6 +64,51 @@ private: static BOOL sEnableMemoryFailurePrevention; }; +//---------------------------------------------------------------------------- +#if MEM_TRACK_MEM +class LLMutex ; +class LL_COMMON_API LLMemTracker +{ +private: + LLMemTracker() ; + ~LLMemTracker() ; + +public: + static void release() ; + static LLMemTracker* getInstance() ; + + void track(const char* function, const int line) ; + void preDraw(BOOL pause) ; + void postDraw() ; + const char* getNextLine() ; + +private: + static LLMemTracker* sInstance ; + + char** mStringBuffer ; + S32 mCapacity ; + U32 mLastAllocatedMem ; + S32 mCurIndex ; + S32 mCounter; + S32 mDrawnIndex; + S32 mNumOfDrawn; + BOOL mPaused; + LLMutex* mMutexp ; +}; + +#define MEM_TRACK_RELEASE LLMemTracker::release() ; +#define MEM_TRACK LLMemTracker::getInstance()->track(__FUNCTION__, __LINE__) ; + +#else // MEM_TRACK_MEM + +#define MEM_TRACK_RELEASE +#define MEM_TRACK + +#endif // MEM_TRACK_MEM + +//---------------------------------------------------------------------------- + + // //class LLPrivateMemoryPool defines a private memory pool for an application to use, so the application does not //need to access the heap directly fro each memory allocation. Throught this, the allocation speed is faster, @@ -195,7 +241,7 @@ public: void dump() ; U32 getTotalAllocatedSize() ; U32 getTotalReservedSize() {return mReservedPoolSize;} - + private: void lock() ; void unlock() ; |