29 #ifndef _MemoryTracker_H__
30 #define _MemoryTracker_H__
36 # pragma message "MemoryTracker included somewhere OgrePrerequisites.h wasn't!"
40 #if OGRE_COMPILER == OGRE_COMPILER_GNUC && OGRE_COMP_VER >= 310 && !defined(STLPORT)
43 # if OGRE_COMP_VER >= 430
44 # include <tr1/unordered_map>
46 # include <ext/hash_map>
49 template <>
struct hash< void* >
51 size_t operator()(
void*
const & ptr )
const
70 #if OGRE_MEMORY_TRACKER
91 Alloc() :bytes(0), line(0) {}
92 Alloc(
size_t sz,
unsigned int p,
const char* file,
size_t ln,
const char* func)
93 :bytes(sz), pool(p), line(ln)
102 std::string mLeakFileName;
104 typedef HashMap<void*, Alloc> AllocationMap;
105 AllocationMap mAllocations;
107 size_t mTotalAllocations;
108 typedef std::vector<size_t> AllocationsByPool;
109 AllocationsByPool mAllocationsByPool;
115 : mLeakFileName(
"OgreLeaks.log"), mDumpToStdOut(true),
122 void setReportFileName(
const std::string& name)
124 mLeakFileName = name;
127 const std::string& getReportFileName()
const
129 return mLeakFileName;
132 void setReportToStdOut(
bool rep)
137 bool getReportToStdOut()
const
139 return mDumpToStdOut;
143 size_t getTotalMemoryAllocated()
const;
145 size_t getMemoryAllocatedForPool(
unsigned int pool)
const;
157 void _recordAlloc(
void* ptr,
size_t sz,
unsigned int pool = 0,
158 const char* file = 0,
size_t ln = 0,
const char* func = 0);
160 void _recordDealloc(
void* ptr);
168 static MemoryTracker&
get();