Fix severe simulation memory leaks

This commit is contained in:
Eduardo Behr 2022-05-28 20:40:24 +00:00 committed by Mikolaj Wielgus
parent b056bbd9b9
commit f246646d7a
4 changed files with 20 additions and 0 deletions

View File

@ -705,4 +705,10 @@ void NGSPICE::validate()
}
void NGSPICE::Clean()
{
Command( "destroy all" );
}
bool NGSPICE::m_initialized = false;

View File

@ -97,6 +97,9 @@ public:
///< @copydoc SPICE_SIMULATOR::GetNetlist()
virtual const std::string GetNetlist() const override final;
///< @copydoc SIMULATOR::Clean()
void Clean() override final;
private:
void init();

View File

@ -481,6 +481,8 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
{
updateTuners();
applyTuners();
// Prevents memory leak on succeding simulations by deleting old vectors
m_simulator->Clean();
m_simulator->Run();
}
else
@ -1641,6 +1643,9 @@ void SIM_PLOT_FRAME::doCloseWindow()
if( m_simulator->IsRunning() )
m_simulator->Stop();
// Prevent memory leak on exit by deleting all simulation vectors
m_simulator->Clean();
// Cancel a running simProbe or simTune tool
m_schematicFrame->GetToolManager()->RunAction( ACTIONS::cancelInteractive );

View File

@ -99,6 +99,12 @@ public:
*/
virtual bool IsRunning() = 0;
/**
* Cleans simulation data (i.e. all vectors)
*
*/
virtual void Clean() = 0;
protected:
///< Model that should be simulated.
std::shared_ptr<SIMULATION_MODEL> m_simModel;