diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/zencore/include/zencore/iobuffer.h | 6 | ||||
| -rw-r--r-- | src/zencore/iobuffer.cpp | 2 |
2 files changed, 7 insertions, 1 deletions
diff --git a/src/zencore/include/zencore/iobuffer.h b/src/zencore/include/zencore/iobuffer.h index da73aab12..0cbf093ca 100644 --- a/src/zencore/include/zencore/iobuffer.h +++ b/src/zencore/include/zencore/iobuffer.h @@ -397,7 +397,11 @@ public: } private: - RefPtr<IoBufferCore> m_Core = new IoBufferCore; + // We have a shared "null" buffer core which we share, this is initialized static and never released which will + // cause a memory leak at exit. This does however save millions of memory allocations for null buffers + static RefPtr<IoBufferCore> NullBufferCore; + + RefPtr<IoBufferCore> m_Core = NullBufferCore; IoBuffer(IoBufferCore* Core) : m_Core(Core) {} diff --git a/src/zencore/iobuffer.cpp b/src/zencore/iobuffer.cpp index e26c361c0..912f9ce4e 100644 --- a/src/zencore/iobuffer.cpp +++ b/src/zencore/iobuffer.cpp @@ -465,6 +465,8 @@ IoBufferExtendedCore::SetDeleteOnClose(bool DeleteOnClose) ////////////////////////////////////////////////////////////////////////// +RefPtr<IoBufferCore> IoBuffer::NullBufferCore(new IoBufferCore); + IoBuffer::IoBuffer(size_t InSize) : m_Core(new IoBufferCore(InSize)) { m_Core->SetIsImmutable(false); |