-
Notifications
You must be signed in to change notification settings - Fork 118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix leak in write_nrnthread
.
#2456
Conversation
✔️ cd3c5fb -> Azure artifacts URL |
Codecov Report
@@ Coverage Diff @@
## master #2456 +/- ##
=======================================
Coverage 60.41% 60.42%
=======================================
Files 626 626
Lines 120812 120799 -13
=======================================
+ Hits 72990 72992 +2
+ Misses 47822 47807 -15
... and 2 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great find, @1uc ! The fix looks good to me, but I prefer if also someone else looks at it.
cd3c5fb
to
0e7d4a2
Compare
✔️ 0e7d4a2 -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✔️ 932cd32 -> Azure artifacts URL |
Just to provide some more explicit explanation, before #2027 we had this logic: nrn/src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp Lines 354 to 360 in b4ade55
where contiguous_art_data allocated new storage that needed to be freed later:nrn/src/nrniv/nrncore_write/io/nrncore_io.cpp Lines 317 to 326 in efc28fe
whereas in master we treat artificial and non-artificial cells uniformly:nrn/src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp Lines 354 to 359 in efc28fe
|
Running a memory profiler on simulations using neurodamus to create the input files for coreneuron in multiple cycles showed that memory allocated in:
nrn/src/nrniv/nrncore_write/callbacks/nrncore_callbacks.cpp
Line 358 in 5ea534f
accumulated across cycles. The function is called from
write_nrnthread
, with the following context:looking into
nrnthread_dat2_mech
we find the following structure:In summary when called from
write_nrnthread
:data
passed tonrnthread_dat2_mech
is unconditionallyNULL
.data
unconditionally.nrn_is_artificial_[type]
which seems to only sometimes hold.The immediate fix is to simply release the memory since it doesn't seem to be used afterwards. Profiling the same run shows the expected reduced memory consumption.