Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR aims to fix the memory leaks in
time_series_observer.cpp
andfile_observer.cpp
.For
file_observer
, thestd::stringstream ss_
that was "collecting" data to write to file has been reduced in scope to a local variable in the functions that used it.For
time_series_observer
, the culprit was the zero argument constructor requesting a buffer size of 0, which bypassed theadjustIfFull
test and led to constantly increasing buffer sizes for all variable types. The zero argument constructor will now instead provide a default buffer size of10000
samples. A zero sample observer is no longer allowed and will throw, the minimum buffer size is 1.The changes have been tested with cosim-cli and memory use found to be stable at 5-6 MB over a 6000 second simulation of the techlaunch-tutorial configuration while logging everything. Running the same simulation on the current master branch leads to memory usage steadily climbing to 10 times that.