Browse Source

plugging moar leaks

Namespace Leaks: these leaks would have been freed on app kill but they were still contaminating the log so free em.
Con::shutdown: gGlobablVars again another leak that would of been freed on app kill
AssetManager onRemove should be clearing its lists
Scripting language needs a free for its strings these destructors free after the rule is executed so the data is cached internally and then freed. This may be needed for other types in the union (should not be used on nodes just raw data)
marauder2k7 8 months ago
parent
commit
e2c4f88faf

+ 10 - 0
Engine/source/assets/assetManager.cpp

@@ -119,6 +119,16 @@ void AssetManager::onRemove()
         mAssetTagsManifest->deleteObject();
     }
 
+    for (auto itr = mDeclaredAssets.begin(); itr != mDeclaredAssets.end(); ++itr)
+    {
+       delete itr->value;
+    }
+    mDeclaredAssets.clear();
+
+    // Clear dependency graphs
+    mAssetDependsOn.clear();
+    mAssetIsDependedOn.clear();
+
     // Call parent.
     Parent::onRemove();
 }

+ 1 - 0
Engine/source/console/console.cpp

@@ -440,6 +440,7 @@ void shutdown()
    Namespace::shutdown();
    AbstractClassRep::shutdown();
    Compiler::freeConsoleParserList();
+   gGlobalVars.reset();
 }
 
 bool isActive()

+ 6 - 0
Engine/source/console/consoleInternal.cpp

@@ -924,6 +924,12 @@ void Namespace::shutdown()
 
    for (Namespace *walk = mNamespaceList; walk; walk = walk->mNext)
       walk->~Namespace();
+
+   gNamespaceCache.clear();
+
+   mNamespaceList = nullptr;
+   mGlobalNamespace = nullptr;
+   mAllocator.freeBlocks();
 }
 
 void Namespace::trashCache()

+ 4 - 0
Engine/source/console/torquescript/CMDgram.y

@@ -102,6 +102,10 @@ struct Token
    IfStmtNode*             ifnode;
 }
 
+
+%destructor { dFree($$.value); } <s>
+%destructor { dFree($$.value); } <str>
+
 %type <s>      parent_block
 %type <ifnode> case_block
 %type <stmt>   switch_stmt

File diff suppressed because it is too large
+ 375 - 329
Engine/source/console/torquescript/cmdgram.cpp


+ 3 - 1
Engine/source/console/torquescript/compiler.cpp

@@ -269,8 +269,10 @@ U32 CompilerStringTable::addFloatString(F64 value)
 
 void CompilerStringTable::reset()
 {
-   list = NULL;
+   // Reset list and associated variables
+   list = nullptr;
    totalLen = 0;
+   hashTable.clear();  // Clear the lookup table too
 }
 
 char *CompilerStringTable::build()

Some files were not shown because too many files changed in this diff