diff --git a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp index d9ce37a45d..56fc57d9aa 100644 --- a/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp +++ b/Generals/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp @@ -217,6 +217,8 @@ ProductionUpdate::~ProductionUpdate( void ) production = m_productionQueue; removeFromProductionQueue( production ); + // TheSuperHackers @fix Mauller 13/04/2025 Delete instance of production item + production->deleteInstance(); } // end while diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp index 8f983f1a9e..03c2c710ad 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp @@ -234,6 +234,8 @@ W3DLaserDraw::~W3DLaserDraw( void ) } // end for i delete [] m_line3D; + // TheSuperHackers @fix Mauller 11/03/2025 Free reference counted material + REF_PTR_RELEASE(m_texture); } //------------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp index 8c178eb322..c409c8610d 100644 --- a/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp +++ b/Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp @@ -163,6 +163,9 @@ void W3DTankDraw::createEmitters( void ) //------------------------------------------------------------------------------------------------- W3DTankDraw::~W3DTankDraw() { + // TheSuperHackers @fix Mauller 16/04/2025 Delete particle systems + tossEmitters(); + for (Int i=0; ifreeDisplayString(m_displayStrings[i]); + // TheSuperHackers @fix Mauller/Tomsons26 28/04/2025 Free benchmark display string + if( m_benchmarkDisplayString ) { + TheDisplayStringManager->freeDisplayString(m_benchmarkDisplayString); + } + // delete 2D renderer if( m_2DRender ) { diff --git a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp b/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp index 11ebc499a3..94730ba482 100644 --- a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp +++ b/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp @@ -77,8 +77,6 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { Int archiveFileSize = 0; Int numLittleFiles = 0; - ArchiveFile *archiveFile = NEW Win32BIGFile; - DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - opening BIG file %s\n", filename)); if (fp == NULL) { @@ -120,6 +118,8 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { fp->seek(0x10, File::START); // read in each directory listing. ArchivedFileInfo *fileInfo = NEW ArchivedFileInfo; + // TheSuperHackers @fix Mauller 23/04/2025 Create new file handle when necessary to prevent memory leak + ArchiveFile *archiveFile = NEW Win32BIGFile; for (Int i = 0; i < numLittleFiles; ++i) { Int filesize = 0; diff --git a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp b/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp index 80cfd4611d..08a5eaaaee 100644 --- a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp +++ b/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp @@ -45,7 +45,6 @@ Win32LocalFileSystem::~Win32LocalFileSystem() { File * Win32LocalFileSystem::openFile(const Char *filename, Int access /* = 0 */) { //USE_PERF_TIMER(Win32LocalFileSystem_openFile) - Win32LocalFile *file = newInstance( Win32LocalFile ); // sanity check if (strlen(filename) <= 0) { @@ -69,6 +68,9 @@ File * Win32LocalFileSystem::openFile(const Char *filename, Int access /* = 0 */ } } + // TheSuperHackers @fix Mauller 21/04/2025 Create new file handle when necessary to prevent memory leak + Win32LocalFile *file = newInstance( Win32LocalFile ); + if (file->open(filename, access) == FALSE) { file->close(); file->deleteInstance(); diff --git a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp index bc96aec7c5..49d1bdc338 100644 --- a/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp +++ b/Generals/Code/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp @@ -102,8 +102,6 @@ MeshModelClass::MeshModelClass(const MeshModelClass & that) : MeshModelClass::~MeshModelClass(void) { -// WWDEBUG_SAY(("Note: Mesh %s was never used\n",Get_Name())); - TheDX8MeshRenderer.Unregister_Mesh_Type(this); Reset(0,0,0); REF_PTR_RELEASE(MatInfo); @@ -141,7 +139,7 @@ MeshModelClass & MeshModelClass::operator = (const MeshModelClass & that) clone_materials(that); if (GapFiller) { - delete[] GapFiller; + delete GapFiller; GapFiller=NULL; } if (that.GapFiller) GapFiller=W3DNEW GapFillerClass(*that.GapFiller); @@ -151,6 +149,11 @@ MeshModelClass & MeshModelClass::operator = (const MeshModelClass & that) void MeshModelClass::Reset(int polycount,int vertcount,int passcount) { + //DMS - We must delete the gapfiller object BEFORE the geometry is reset. Otherwise, + // the number of stages and passes gets reset and the gapfiller cannot deallocate properly. + delete GapFiller; + GapFiller=NULL; + Reset_Geometry(polycount,vertcount); // Release everything we have and reset to initial state @@ -165,9 +168,6 @@ void MeshModelClass::Reset(int polycount,int vertcount,int passcount) } CurMatDesc = DefMatDesc; - delete GapFiller; - GapFiller=NULL; - return ; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Snow.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Snow.cpp index dd926de453..e2617586b6 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Snow.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Snow.cpp @@ -99,6 +99,13 @@ SnowManager::~SnowManager() { delete [] m_startingHeights; m_startingHeights=NULL; + + // TheSuperHackers @fix Mauller 13/04/2025 Delete the instance of the weather settings + if (TheWeatherSetting) + { + ((WeatherSetting*)TheWeatherSetting.getNonOverloadedPointer())->deleteInstance(); + TheWeatherSetting=NULL; + } } OVERRIDE TheWeatherSetting = NULL; diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp index 8ee4716c02..662d651266 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp @@ -218,6 +218,8 @@ ProductionUpdate::~ProductionUpdate( void ) production = m_productionQueue; removeFromProductionQueue( production ); + // TheSuperHackers @fix Mauller 13/04/2025 Delete instance of production item + production->deleteInstance(); } // end while diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp index ec8dec496e..31ef5c6582 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp @@ -237,6 +237,8 @@ W3DLaserDraw::~W3DLaserDraw( void ) } // end for i delete [] m_line3D; + // TheSuperHackers @fix Mauller 11/03/2025 Free reference counted material + REF_PTR_RELEASE(m_texture); } //------------------------------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp index a11d314430..269a56b033 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp @@ -163,6 +163,9 @@ void W3DTankDraw::createEmitters( void ) //------------------------------------------------------------------------------------------------- W3DTankDraw::~W3DTankDraw() { + // TheSuperHackers @fix Mauller 16/04/2025 Delete particle systems + tossEmitters(); + for (Int i=0; ifreeDisplayString(m_displayStrings[i]); + // TheSuperHackers @fix Mauller/Tomsons26 28/04/2025 Free benchmark display string + if( m_benchmarkDisplayString ) { + TheDisplayStringManager->freeDisplayString(m_benchmarkDisplayString); + } + // delete 2D renderer if( m_2DRender ) { diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp index e9c0bc91e2..8ba95f2adb 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp @@ -90,8 +90,6 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { Int archiveFileSize = 0; Int numLittleFiles = 0; - ArchiveFile *archiveFile = NEW Win32BIGFile; - DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - opening BIG file %s\n", filename)); if (fp == NULL) { @@ -133,6 +131,8 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { fp->seek(0x10, File::START); // read in each directory listing. ArchivedFileInfo *fileInfo = NEW ArchivedFileInfo; + // TheSuperHackers @fix Mauller 23/04/2025 Create new file handle when necessary to prevent memory leak + ArchiveFile *archiveFile = NEW Win32BIGFile; for (Int i = 0; i < numLittleFiles; ++i) { Int filesize = 0; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp index 19b78e8770..e1f00f7334 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp +++ b/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp @@ -45,7 +45,6 @@ Win32LocalFileSystem::~Win32LocalFileSystem() { File * Win32LocalFileSystem::openFile(const Char *filename, Int access /* = 0 */) { //USE_PERF_TIMER(Win32LocalFileSystem_openFile) - Win32LocalFile *file = newInstance( Win32LocalFile ); // sanity check if (strlen(filename) <= 0) { @@ -69,6 +68,9 @@ File * Win32LocalFileSystem::openFile(const Char *filename, Int access /* = 0 */ } } + // TheSuperHackers @fix Mauller 21/04/2025 Create new file handle when necessary to prevent memory leak + Win32LocalFile *file = newInstance( Win32LocalFile ); + if (file->open(filename, access) == FALSE) { file->close(); file->deleteInstance(); diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp index 531552433c..5d8b9876b0 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp +++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/meshmdl.cpp @@ -106,8 +106,6 @@ MeshModelClass::MeshModelClass(const MeshModelClass & that) : MeshModelClass::~MeshModelClass(void) { -// WWDEBUG_SAY(("Note: Mesh %s was never used\n",Get_Name())); - TheDX8MeshRenderer.Unregister_Mesh_Type(this); Reset(0,0,0); REF_PTR_RELEASE(MatInfo);