From 657213f13d49f0d2caaa8b64c1245ec8c75fc4d7 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 24 Jul 2024 11:44:13 -0700 Subject: Cleanup global memory allocations on shutdown. (#4731) Co-authored-by: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> --- include/slang.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/slang.h b/include/slang.h index 6fd6da7b2..849532fc8 100644 --- a/include/slang.h +++ b/include/slang.h @@ -5351,6 +5351,14 @@ Returns nullptr if there isn't an embedded stdlib. */ SLANG_API ISlangBlob* slang_getEmbeddedStdLib(); + +/* Cleanup all global allocations used by Slang, to prevent memory leak detectors from + reporting them as leaks. This function should only be called after all Slang objects + have been released. No other Slang functions such as `createGlobalSession` + should be called after this function. + */ +SLANG_EXTERN_C SLANG_API void slang_shutdown(); + namespace slang { inline SlangResult createGlobalSession( @@ -5358,6 +5366,7 @@ namespace slang { return slang_createGlobalSession(SLANG_API_VERSION, outGlobalSession); } + inline void shutdown() { slang_shutdown(); } } /** @see slang::ICompileRequest::getProgram -- cgit v1.2.3