Fixing YAXT index list related memory leaks in generation of redistribution map - #448
Fixing YAXT index list related memory leaks in generation of redistribution map#448DrTVockerodtMO wants to merge 5 commits into
Conversation
|
DrTVockerodtMO I imagine that a test using a memory leak detection tool has been carried out after applying this bug fix. It would be great if you could add a link to the log file associated to the test or if you could just report here the key info (summary) from this file. |
Good point. I ran a simplified version of the Before After In the first scenario, there were blocks present that lead me to the memory leak that looked like: After making the change, I cannot find any reference to |
|
I have looked at the codebase and the changes that you are proposing. I believe that the current memory leak originates from another part of the codebase, possibly in a different file. Therefore, addressing this issue requires further investigation. |
Thanks for having a look. A couple of questions: It's my general understanding that for objects the clean-up of memory ought to happen in the destructor. But the I think the only case where we wouldn't need to do this is if the index lists freed the memory in their own destructor, which ought to be called as they are going out of scope. In which case, https://github.com/DrTVockerodtMO/lfric_core/blob/4de4f3d9b7b430181f1f93534f21eb256b19c138/infrastructure/source/utilities/halo_comms_mod.F90#L910 and https://github.com/DrTVockerodtMO/lfric_core/blob/4de4f3d9b7b430181f1f93534f21eb256b19c138/infrastructure/source/utilities/halo_comms_mod.F90#L911 should also need to be removed no? These were not added by this PR and have been there for quite some time, even back to the ticket you linked. Which file did you have in mind for where the memory leak would originate? |
|
On a second look it actually doesn't seem that the |
I can confirm that this passes the test-suite which is now attached, and also produces the same output as the previous solution did when using Valgrind. |
You should also run the |
I did this on the |
Added this to the PR description! |
|
Thanks for the further info ... Have you used a memory leak detection tool after applying these latest changes? |
I can share the results sure. Again, I ran a simplified version of the Before this PR After first set of changes (deallocating index lists) After second set of changes (removing unused index lists) The first and second sets of changes are practically identical and indicate a definite reduction in the memory leaked. In the first scenario (before this PR), there were blocks present that lead me to the memory leak that looked like: These blocks are once again no longer present in either Valgrind logs of both changesets, indicating this particular leak relating to L848 of |
|
Thanks for sharing the output of the memory checks. If I understand correctly, these changes address some (but not all) of the memory leaks. |
Thank you. It is correct that this only addresses part of the memory leaks of that file, I wanted to keep the PR agile. :) |
PR Summary
Sci/Tech Reviewer: Lorenzo Milazzo (@mo-lormi)
Code Reviewer: Andrew Coughtrie (@andrewcoughtrie)
The locally scoped source and target index lists used to generate the redistribution map are allocated but never freed. YAXT has routines to free the memory of its index lists which are used in the same file in the generation of the exchange maps. I have replicated this for the redistribution maps.
EDIT: These index lists actually do not appear to be doing anything in this routine and have been removed instead.
Code Quality Checklist
Testing
trac.log
Test Suite Results - lfric_core - mem_leak_idxlists/run2
Suite Information
Task Information
✅ succeeded tasks - 433
Test Suite Results - lfric_apps - linked_mem_leak_idxlists/run2
Suite Information
Task Information
✅ succeeded tasks - 1218
Security Considerations
Performance Impact
AI Assistance and Attribution
Documentation
PSyclone Approval
Sci/Tech Review
(Please alert the code reviewer via a tag when you have approved the SR)
Code Review