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 from cellLimitField in mpas_block_creator_build_cell_halos #1264

Merged

Conversation

mgduda
Copy link
Contributor

@mgduda mgduda commented Jan 10, 2025

This PR fixes a memory leak in mpas_block_creator_build_cell_halos by deallocating the cellLimitField field before the routine returns.

The cellLimitField field is allocated in the mpas_block_creator_build_cell_halos routine and is only used in a call therein to mpas_dmpar_get_exch_list. If not deallocated at the end of the mpas_block_creator_build_cell_halos routine, the memory allocated to cellLimitField would be otherwise be leaked, since there is nothing outisde of the mpas_block_creator_build_cell_halos routine that retains a reference to it and deallocates it.

…halos

The cellLimitField field is allocated in the mpas_block_creator_build_cell_halos
routine and is only used in a call therein to mpas_dmpar_get_exch_list. If not
deallocated at the end of the mpas_block_creator_build_cell_halos routine, the
memory allocated to cellLimitField would be otherwise be leaked, since there
is nothing outisde of the mpas_block_creator_build_cell_halos routine that
retains a reference to it and deallocates it.

This commit fixes this memory leak by deallocating cellLimitField before the
mpas_block_creator_build_cell_halos routine returns.
@mgduda mgduda force-pushed the framework/fix_cellLimitField_leak branch from 2384910 to 90f7ecc Compare January 10, 2025 21:01
@mgduda mgduda requested a review from abishekg7 January 10, 2025 21:01
Copy link
Collaborator

@abishekg7 abishekg7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good, and model runs to the finish. However, I'm not able to pinpoint the exact differences in the valgrind outputs between the base version and this PR, as there are many other diagnostic messages as well. But this can be discussed later.

mgduda added a commit that referenced this pull request Feb 4, 2025
This merge fixes a memory leak in mpas_block_creator_build_cell_halos by
deallocating the cellLimitField field before the routine returns.

The cellLimitField field is allocated in the mpas_block_creator_build_cell_halos
routine and is only used in a call therein to mpas_dmpar_get_exch_list. If not
deallocated at the end of the mpas_block_creator_build_cell_halos routine, the
memory allocated to cellLimitField would be otherwise be leaked, since there is
nothing outisde of the mpas_block_creator_build_cell_halos routine that retains
a reference to it and deallocates it.

* framework/fix_cellLimitField_leak:
  Fix memory leak from cellLimitField in mpas_block_creator_build_cell_halos
@mgduda mgduda merged commit 283c77f into MPAS-Dev:hotfix-v8.2.3 Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants