diff options
| author | Yong He <yonghe@outlook.com> | 2018-02-20 23:55:51 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-20 23:55:51 -0500 |
| commit | 01c4134d33cea3a4f98fad9248584278fd4bc452 (patch) | |
| tree | 8ca6b0f7e844fbf56cb1991284aff3ebbcc8aa89 /source/slang/slang.cpp | |
| parent | 51cdcad24b5271ac8c0f816174c6a760e264ed9e (diff) | |
| parent | 4cf46e5c8b2af8a4ea4db15cd402aae4145a614c (diff) | |
Merge pull request #417 from csyonghe/leakfix
Fix IR memory leaks.
Diffstat (limited to 'source/slang/slang.cpp')
| -rw-r--r-- | source/slang/slang.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp index 4238681f3..42e412438 100644 --- a/source/slang/slang.cpp +++ b/source/slang/slang.cpp @@ -123,7 +123,13 @@ CompileRequest::CompileRequest(Session* session) } CompileRequest::~CompileRequest() -{} +{ + // delete things that may reference IR objects first + targets = decltype(targets)(); + translationUnits = decltype(translationUnits)(); + entryPoints = decltype(entryPoints)(); + types = decltype(types)(); +} RefPtr<Expr> CompileRequest::parseTypeString(TranslationUnitRequest * translationUnit, String typeStr, RefPtr<Scope> scope) @@ -734,6 +740,19 @@ void Session::addBuiltinSource( loadedModuleCode.Add(syntax); } +Session::~Session() +{ + // free all built-in types first + errorType = nullptr; + initializerListType = nullptr; + overloadedType = nullptr; + irBasicBlockType = nullptr; + + builtinTypes = decltype(builtinTypes)(); + // destroy modules next + loadedModuleCode = decltype(loadedModuleCode)(); +} + } // implementation of C interface @@ -751,6 +770,9 @@ SLANG_API void spDestroySession( { if(!session) return; delete SESSION(session); +#ifdef _MSC_VER + _CrtDumpMemoryLeaks(); +#endif } SLANG_API void spAddBuiltins( |
