diff options
| author | Dan Engelbrecht <[email protected]> | 2023-11-06 11:38:25 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-06 11:38:25 +0100 |
| commit | 8666753b150538130678b406cf27dac5b3b52cd7 (patch) | |
| tree | f14a9c42af5c8ce501889c398fbc53b92e36b938 /src | |
| parent | individual gc stats (#506) (diff) | |
| download | zen-8666753b150538130678b406cf27dac5b3b52cd7.tar.xz zen-8666753b150538130678b406cf27dac5b3b52cd7.zip | |
keep a "null" iobuffer core to reduce redundant memory allocations (#507)
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); |