1
0

LeakFinder: Factored in the housekeeping overhead

git-svn-id: http://mc-server.googlecode.com/svn/trunk@1310 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
madmaxoft@gmail.com 2013-03-24 17:19:59 +00:00
parent 513d67025f
commit 398edefe06

View File

@ -393,8 +393,8 @@ protected:
virtual LONG Disable() = 0; virtual LONG Disable() = 0;
// enables the leak-finder again... // enables the leak-finder again...
virtual LONG Enable() = 0; virtual LONG Enable() = 0;
private: protected:
// Entry for each allocation // Entry for each allocation
typedef struct AllocHashEntryType { typedef struct AllocHashEntryType {
HASHTABLE_KEY key; HASHTABLE_KEY key;
@ -678,6 +678,9 @@ static LONG s_CrtDisableCount = 0;
static LONG s_lMallocCalled = 0; static LONG s_lMallocCalled = 0;
class CRTTable : public ContextHashtableBase<LONG> class CRTTable : public ContextHashtableBase<LONG>
{ {
public: public:
@ -725,6 +728,8 @@ public:
#endif #endif
} }
static const int AllocHashEntryTypeSize = sizeof(AllocHashEntryType);
protected: protected:
CHAR *m_pBuffer; CHAR *m_pBuffer;
SIZE_T m_maxBufferLen; SIZE_T m_maxBufferLen;
@ -885,9 +890,9 @@ static int MyAllocHook(int nAllocType, void *pvData,
{ {
if (lRequest != 0) // Always a valid RequestID should be provided (see comments in the header) if (lRequest != 0) // Always a valid RequestID should be provided (see comments in the header)
{ {
g_CurrentMemUsage += nSize; g_CurrentMemUsage += nSize + CRTTable::AllocHashEntryTypeSize;
if (g_CurrentMemUsage > 65970823)//1024 * 1024 * 1024) if (g_CurrentMemUsage > 1024 * 1024 * 1024)
{ {
printf("******************************************\n"); printf("******************************************\n");
printf("** Server reached 1 GiB memory usage, **\n"); printf("** Server reached 1 GiB memory usage, **\n");