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

Add explicit grid destroy when deleting Regridder #387

Merged
merged 3 commits into from
Oct 11, 2024

Conversation

aulemahal
Copy link
Collaborator

Fixes JiaweiZhuang/xESMF#53.

When the Regridder or SpatialAverager object is garage-collected, the ESMpy grid objects are not destroyed as they seem to still be referenced somewhere in the ESMpy Manager (or something alike). This change explicitly destroys the grids when the Regridder object is removed.

This will break any code that makes use of the Grid objects in a scope where the Regridder itself is not referenced. For example:

import xesmf as xe

def get_grid(ds1, ds2):
    reg = xe.Regridder(ds, ds2)
    return reg.grid_in    

Will most likely return a destroyed grid object.

The other solution I see is to make a destroy method on the Regridder object that destroys underlying grids, but that demands an explicit action from the user. It won't really fix the "memory leak" feeling that users get.

@raphaeldussin raphaeldussin merged commit 8a902b1 into master Oct 11, 2024
11 checks passed
@raphaeldussin raphaeldussin deleted the fix-memory-leak branch October 11, 2024 13:05
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.

High memory usage
2 participants