Fix display of live chunk count

This commit is contained in:
baldurk
2017-12-14 18:39:18 +00:00
parent 26d879df12
commit 64ab04c42c
2 changed files with 21 additions and 3 deletions
-1
View File
@@ -33,7 +33,6 @@
int64_t Chunk::m_LiveChunks = 0;
int64_t Chunk::m_TotalMem = 0;
int64_t Chunk::m_MaxChunks = 0;
#endif
+21 -2
View File
@@ -1718,7 +1718,16 @@ class ScopedChunk;
class Chunk
{
public:
~Chunk() { FreeAlignedBuffer(m_Data); }
~Chunk()
{
FreeAlignedBuffer(m_Data);
#if !defined(RELEASE)
Atomic::Dec64(&m_LiveChunks);
Atomic::ExchAdd64(&m_TotalMem, -int64_t(m_Length));
#endif
}
template <typename ChunkType>
ChunkType GetChunkType()
{
@@ -1746,6 +1755,11 @@ public:
memcpy(m_Data, ser.GetWriter()->GetData(), (size_t)m_Length);
ser.GetWriter()->Rewind();
#if !defined(RELEASE)
Atomic::Inc64(&m_LiveChunks);
Atomic::ExchAdd64(&m_TotalMem, int64_t(m_Length));
#endif
}
byte *GetData() const { return m_Data; }
@@ -1759,6 +1773,11 @@ public:
memcpy(ret->m_Data, m_Data, (size_t)m_Length);
#if !defined(RELEASE)
Atomic::Inc64(&m_LiveChunks);
Atomic::ExchAdd64(&m_TotalMem, int64_t(m_Length));
#endif
return ret;
}
@@ -1780,7 +1799,7 @@ private:
byte *m_Data;
#if !defined(RELEASE)
static int64_t m_LiveChunks, m_MaxChunks, m_TotalMem;
static int64_t m_LiveChunks, m_TotalMem;
#endif
};