Memory Management : Adjustment and fixes

Add release of several static singleton objects
Fix several minor memory leaks
This commit is contained in:
Magne Sjaastad
2022-03-03 10:15:32 +01:00
parent 7a2a297648
commit 0e57cfe201
36 changed files with 441 additions and 141 deletions

View File

@@ -18,6 +18,7 @@
#include "RiaArgumentParser.h"
#include "RiaLogging.h"
#include "RiaMainTools.h"
#ifdef ENABLE_GRPC
#include "RiaGrpcConsoleApplication.h"
@@ -26,6 +27,7 @@
#include "RiaConsoleApplication.h"
#include "RiaGuiApplication.h"
#endif
#include "cvfProgramOptions.h"
#include "cvfqtUtils.h"
@@ -66,8 +68,12 @@ int main( int argc, char* argv[] )
return 1;
}
#endif
// Global initialization
RiaLogging::loggerInstance()->setLevel( int( RILogLevel::RI_LL_DEBUG ) );
// Create feature manager before the application object is created
RiaMainTools::initializeSingletons();
std::unique_ptr<RiaApplication> app( createApplication( argc, argv ) );
cvf::ProgramOptions progOpt;
@@ -112,6 +118,9 @@ int main( int argc, char* argv[] )
// Make sure project is closed to avoid assert and crash in destruction of widgets
app->closeProject();
app.reset();
RiaMainTools::releaseSingletonAndFactoryObjects();
return 0;
}
else if ( status == RiaApplication::ApplicationStatus::EXIT_WITH_ERROR )
@@ -147,6 +156,9 @@ int main( int argc, char* argv[] )
throw;
}
app.reset();
RiaMainTools::releaseSingletonAndFactoryObjects();
return exitCode;
}