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

Patch memory leak when saving to Zarr #915

Merged
merged 1 commit into from Aug 29, 2022

Conversation

alejoe91
Copy link
Member

When saving to ZARR with parallel writing, somehow the RAM usage of each job kept increasing, causing out-of-memory error.

After some debugging, I found that deleting the traces and forcing garbage collection fixes it. It's a patch, but it doesn't seem to affect speed..

@alejoe91
Copy link
Member Author

@samuelgarcia

@@ -703,6 +704,10 @@ def _write_zarr_chunk(segment_index, start_frame, end_frame, worker_ctx):
traces = traces.astype(dtype)
zarr_dataset[start_frame:end_frame, :] = traces

# fix memory leak by forcing garbage collection
del traces
gc.collect()
Copy link
Member

Choose a reason for hiding this comment

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

does it works without the gc.collect() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

No 😧

Copy link
Member Author

Choose a reason for hiding this comment

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

I mean it works but the jobs keep accumulating RAM

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is also something that I think we encountered with hdf5 or memap arrays. You need to regularly force the destruction of the objects to clear the built-in caches that they have, in order to prevent memory leaks

@samuelgarcia samuelgarcia merged commit 4633750 into SpikeInterface:master Aug 29, 2022
@alejoe91 alejoe91 deleted the zarr_memory_leak branch September 8, 2022 14:09
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.

None yet

3 participants