summaryrefslogtreecommitdiffstats
path: root/source/slang
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-07-24 11:44:13 -0700
committerGitHub <noreply@github.com>2024-07-24 11:44:13 -0700
commit657213f13d49f0d2caaa8b64c1245ec8c75fc4d7 (patch)
tree02f2a6dca56ea384c88095e75b24691d5253d204 /source/slang
parenta1607f802ae0a42ffafd2c37d76779873264d371 (diff)
Cleanup global memory allocations on shutdown. (#4731)
Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com>
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-api.cpp13
-rw-r--r--source/slang/slang-capability.h2
-rw-r--r--source/slang/slang.cpp2
3 files changed, 14 insertions, 3 deletions
diff --git a/source/slang/slang-api.cpp b/source/slang/slang-api.cpp
index c4f668fb2..412cec0d4 100644
--- a/source/slang/slang-api.cpp
+++ b/source/slang/slang-api.cpp
@@ -1,9 +1,10 @@
// slang-api.cpp
#include "slang-compiler.h"
-
#include "slang-repro.h"
-
+#include "slang-capability.h"
+#include "../core/slang-rtti-info.h"
+#include "../core/slang-performance-profiler.h"
#include "../core/slang-shared-library.h"
#include "../slang-record-replay/record/slang-global-session.h"
#include "../slang-record-replay/util/record-utility.h"
@@ -139,6 +140,14 @@ SLANG_API SlangResult slang_createGlobalSession(
return SLANG_OK;
}
+SLANG_API void slang_shutdown()
+{
+ Slang::PerformanceProfiler::getProfiler()->dispose();
+ Slang::SPIRVCoreGrammarInfo::freeEmbeddedGrammerInfo();
+ Slang::RttiInfo::deallocateAll();
+ Slang::freeCapabilityDefs();
+}
+
SLANG_API SlangResult slang_createGlobalSessionWithoutStdLib(
SlangInt apiVersion,
slang::IGlobalSession** outGlobalSession)
diff --git a/source/slang/slang-capability.h b/source/slang/slang-capability.h
index 299e956e4..79b1f7068 100644
--- a/source/slang/slang-capability.h
+++ b/source/slang/slang-capability.h
@@ -371,6 +371,8 @@ const CapabilityAtomSet& getAtomSetOfStages();
bool hasTargetAtom(const CapabilityAtomSet& setIn, CapabilityAtom& targetAtom);
+void freeCapabilityDefs();
+
//#define UNIT_TEST_CAPABILITIES
#ifdef UNIT_TEST_CAPABILITIES
void TEST_CapabilitySet();
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index c6e460d02..6f5e79458 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -140,7 +140,7 @@ void Session::init()
{
SLANG_ASSERT(BaseTypeInfo::check());
-
+
_initCodeGenTransitionMap();
::memset(m_downstreamCompilerLocators, 0, sizeof(m_downstreamCompilerLocators));