-
Notifications
You must be signed in to change notification settings - Fork 3
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
Possible memory leak when opening a netCDF-4 file #3
Comments
Strange. There is not much code involved that could leak. It basically wraps netcdf open/close and that's it. Could you try to run it with Xcode memory leak profiler to see where the leak occurs? I suspect the leak will be inside the NetCDF/HDF5 library. |
These are the stacktraces of allocations over a 4 minute window which didn't get deallocated in the following 4 minutes, and they do occur in the NetCDF/HDF5 libraries. The growing memory use doesn't get classified as a leak as it seems to still be reachable, but not enough get deallocated.
The relative distribution of allocations mostly matches the the distribution which I profiled on Linux (by which I mean the source of the leak seems to be the same on MacOS and Linux). |
As expected everything is happening inside the C NetCDF4/HDF5 library. This Swift wrapper is not causing this leak. HDF5 is using a cache when reading compressed chunks. Maybe there is a way to clear it (or disable it for testing). You can also open NetCDF4 files directly with HDF5 to get better control. I once started to implement a native HDF5 Swift implementation, but stopped at decoding compressed chunks. The binary HDF5 format is however relatively easy to understand. |
Any news? Otherwise please consider closing this ticket, as I assume the NetCDF4/HDF5 library is causing the leak |
I have opened a issue at Unidata/netcdf-c#2589 |
Good work on catching the leak in the HDF library. Much appreciated! |
When running:
the memory consumption keeps growing. In this case it hit 346 MiB after 10 minutes, when I shut it down.
Note
I tested this with
GOTEX.C130-example.nc
,smith_sandwell_topo_v8_2.nc
,sresa1b_ncar_ccsm3-example.nc
,test_echam_spectral-deflated.nc
andtest_echam_spectral.nc
from https://www.unidata.ucar.edu/software/netcdf/examples/files.html and onlytest_echam_spectral-deflated.nc
showed this behaviour.The text was updated successfully, but these errors were encountered: