fix memory leak#1554
Conversation
- add recruitment shared pointers to clear function - add functionality in FIMSObject to track objects for memory leak test and identify source module for memory leak - add memory leak test
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1554 +/- ##
==========================================
+ Coverage 83.52% 87.48% +3.96%
==========================================
Files 55 98 +43
Lines 2197 8813 +6616
Branches 516 540 +24
==========================================
+ Hits 1835 7710 +5875
- Misses 292 1065 +773
+ Partials 70 38 -32 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
I noticed in the build metrics reports: |
|
@Andrea-Havron-NOAA the build metric has been highly variable for that one, with very small changes leading to 25% differences so I think it is just the instability of the runner. We need to change the threshold for that metric as Matthew pointed out to me before. But, I am curious to hear what @msupernaw thinks about the code to help debug that is in this PR. |
|
@Andrea-Havron-NOAA and @kellijohnson-NOAA That metric is vulnerable to all kinds of influence like system state. It only becomes informative when peak RSS increases, which is reported directly from the kernel. I would not expect peak RSS to move much unless we create a TU larger than TMB.o. |
What is the feature?
How have you implemented the solution?
Does the PR impact any other area of the project, maybe another repo?
I was able to track down which pointers were not being cleared using a new memory test that adds module registration for memory tracking purposes. The clear function now will throw an error if there is an uncleared pointer and will list the base class and module id. For example, I used the following warning to track down the uncleared pointers were coming from RecruitmentBase:
The following 4 C++ heap object(s) were NOT destroyed:
❌ Leaked: fims_popdy::RecruitmentBaseTMBad::global::ad_aug [id=0]
❌ Leaked: fims_popdy::RecruitmentBaseTMBad::global::ad_aug [id=1]
❌ Leaked: fims_popdy::RecruitmentBase [id=0]
❌ Leaked: fims_popdy::RecruitmentBase [id=1]
Ensure all std::shared_ptrs to these types are being reset.
Instructions for code reviewer
👋Hello reviewer👋, thank you for taking the time to review this PR!
nit:(for nitpicking) as the comment type. For example,nit:I prefer using adata.frame()instead of amatrixbecause ...This PR is now ready to be merged.Checklist