diff options
| -rw-r--r-- | source/core/slang-rtti-info.cpp | 10 | ||||
| -rw-r--r-- | source/core/slang-rtti-info.h | 5 | ||||
| -rw-r--r-- | tools/slang-test/slang-test-main.cpp | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/source/core/slang-rtti-info.cpp b/source/core/slang-rtti-info.cpp index f53cf742f..043e6490a 100644 --- a/source/core/slang-rtti-info.cpp +++ b/source/core/slang-rtti-info.cpp @@ -39,6 +39,11 @@ struct RttiInfoManager std::lock_guard<std::recursive_mutex> guard(m_mutex); return m_arena.allocate(size); } + void deallocateAll() + { + std::lock_guard<std::recursive_mutex> guard(m_mutex); + m_arena.reset(); + } static RttiInfoManager& getSingleton() { @@ -61,6 +66,11 @@ protected: return RttiInfoManager::getSingleton().allocate(size); } +/* static */void RttiInfo::deallocateAll() +{ + return RttiInfoManager::getSingleton().deallocateAll(); +} + /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! StructRttiBuilder !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */ static void _appendFixedArray(const FixedArrayRttiInfo* inFixedArray, StringBuilder& out) diff --git a/source/core/slang-rtti-info.h b/source/core/slang-rtti-info.h index 09a4bf657..36651c32b 100644 --- a/source/core/slang-rtti-info.h +++ b/source/core/slang-rtti-info.h @@ -109,6 +109,11 @@ struct RttiInfo /// Is thread safe, and doesn't require the memory to be freed explicitly /// Will be freed at shutdown (via global dtor) static void* allocate(size_t size); + /// Will free up any allocations. Can only be called at shutdown, and there are guarenteed no uses of + /// RttiInfo - otherwise contents may be undefined. + /// NOTE! Memory *will* be freed with final dtors, but if memory check functions are used they can report + /// this memory. + static void deallocateAll(); static bool isIntegral(RttiInfo::Kind kind) { return Index(kind) >= Index(RttiInfo::Kind::I32) && Index(kind) <= Index(RttiInfo::Kind::U64); } static bool isFloat(RttiInfo::Kind kind) { return kind == RttiInfo::Kind::F32 || kind == RttiInfo::Kind::F64; } diff --git a/tools/slang-test/slang-test-main.cpp b/tools/slang-test/slang-test-main.cpp index 9648b2ed1..ac8ec0e10 100644 --- a/tools/slang-test/slang-test-main.cpp +++ b/tools/slang-test/slang-test-main.cpp @@ -3752,6 +3752,9 @@ SlangResult innerMain(int argc, char** argv) int main(int argc, char** argv) { const SlangResult res = innerMain(argc, argv); + + Slang::RttiInfo::deallocateAll(); + #ifdef _MSC_VER _CrtDumpMemoryLeaks(); #endif |
