You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the library, I am encountering a memory leak in the situation where the program exits when the FMU is not in a state where terminate is allowed to be called. For example, if an exception is thrown after enter_initialization_mode() is called, but before exit_initialization_mode() is called. I looked at the destructor in the fmu_instance_base class, and it is calling terminate(), which attempts to terminate the FMU and free the resources:
boolterminate(bool freeInstance)
{
if (!this->terminated_) {
this->terminated_ = true;
if (!library_->terminate(c_)) {
returnfalse;
}
this->free_instance();
}
returntrue;
}
However, if the library fails to terminate the FMU, the function returns early with false, and the free_instance() function is never called. This corresponds to fmi2FreeInstance, which should be callable even when the FMU is not terminated. It could be changed to something like the following.
I'll see if I can look into this not to long into the future. I notice that bool freeInstance is not actually used, so the code path needs some cleanup regardless.
When using the library, I am encountering a memory leak in the situation where the program exits when the FMU is not in a state where terminate is allowed to be called. For example, if an exception is thrown after
enter_initialization_mode()
is called, but beforeexit_initialization_mode()
is called. I looked at the destructor in thefmu_instance_base
class, and it is callingterminate()
, which attempts to terminate the FMU and free the resources:However, if the library fails to terminate the FMU, the function returns early with
false
, and thefree_instance()
function is never called. This corresponds tofmi2FreeInstance
, which should be callable even when the FMU is not terminated. It could be changed to something like the following.Or the call to
free_instance
can be removed fromterminate
and simply called from the destructor like:The text was updated successfully, but these errors were encountered: