summaryrefslogtreecommitdiffstats
path: root/source/slang/slang.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2018-02-19 19:53:45 -0500
committerYong He <yonghe@outlook.com>2018-02-19 19:53:45 -0500
commit5de62bbe4dddc64895ddb17c4eb3572c3c9be248 (patch)
treed12fd2a9bad9a632430e1262de8f7e7da388bffa /source/slang/slang.cpp
parentff8adf7b45121aada0b4f4403b0f45a6e2dfe475 (diff)
more to fixing memory leaks
1. reorder destruction order of several key classes to avoid using deleted IR objects when destroying Types 2. remove Session::canonicalTypes and make each Type own a RefPtr to the canonicalType, to allow types to be destroyed along with each IRModule it belongs to.
Diffstat (limited to 'source/slang/slang.cpp')
-rw-r--r--source/slang/slang.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/slang/slang.cpp b/source/slang/slang.cpp
index 0f5d8e17a..b65ec5615 100644
--- a/source/slang/slang.cpp
+++ b/source/slang/slang.cpp
@@ -734,6 +734,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