Skip to content
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 memory leak during ini parsing #278

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

tim-griesbach
Copy link
Contributor

During testing of the ForestClaw restart code with valgrind I found a memory leak in the ini parsing.
For swirl I am getting the following error report by valgrind.

==881976== 
==881976== HEAP SUMMARY:
==881976==     in use at exit: 5,615 bytes in 221 blocks
==881976==   total heap usage: 22,016 allocs, 21,795 frees, 31,015,194 bytes allocated
==881976== 
==881976== 488 bytes in 5 blocks are definitely lost in loss record 3 of 8
==881976==    at 0x483877F: malloc (vg_replace_malloc.c:307)
==881976==    by 0x221B6D: iniparser_getseckeys (in /home/griesbac/forestclaw_workspace/forestclaw-debug/applications/clawpack/advection/2d/swirl/swirl)
==881976==    by 0x13A109: fclaw_app_options_parse (in /home/griesbac/forestclaw_workspace/forestclaw-debug/applications/clawpack/advection/2d/swirl/swirl)
==881976==    by 0x10CCE0: main (in /home/griesbac/forestclaw_workspace/forestclaw-debug/applications/clawpack/advection/2d/swirl/swirl)
==881976== 
==881976== 5,127 (32 direct, 5,095 indirect) bytes in 1 blocks are definitely lost in loss record 8 of 8
==881976==    at 0x483AB65: calloc (vg_replace_malloc.c:760)
==881976==    by 0x223243: dictionary_new (in /home/griesbac/forestclaw_workspace/forestclaw-debug/applications/clawpack/advection/2d/swirl/swirl)
==881976==    by 0x221E74: iniparser_load (in /home/griesbac/forestclaw_workspace/forestclaw-debug/applications/clawpack/advection/2d/swirl/swirl)
==881976==    by 0x139F3C: fclaw_app_options_parse (in /home/griesbac/forestclaw_workspace/forestclaw-debug/applications/clawpack/advection/2d/swirl/swirl)
==881976==    by 0x10CCE0: main (in /home/griesbac/forestclaw_workspace/forestclaw-debug/applications/clawpack/advection/2d/swirl/swirl)
==881976== 
==881976== LEAK SUMMARY:
==881976==    definitely lost: 520 bytes in 6 blocks
==881976==    indirectly lost: 5,095 bytes in 215 blocks
==881976==      possibly lost: 0 bytes in 0 blocks
==881976==    still reachable: 0 bytes in 0 blocks
==881976==         suppressed: 0 bytes in 0 blocks
==881976== 
==881976== For lists of detected and suppressed errors, rerun with: -s
==881976== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)

I resolved the issue by adding the missing memory free calls in the static function check_for_unused_options.

@scottaiton scottaiton merged commit 77d3926 into ForestClaw:develop Sep 20, 2023
35 checks passed
@tim-griesbach tim-griesbach deleted the fix-ini-mem-leak branch September 28, 2023 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants