Skip to content

Fixing memory leaks - #74

Merged
lazarusA merged 4 commits into
mainfrom
fix-memleaks
Oct 30, 2026
Merged

lazarusA merged 4 commits into
mainfrom
fix-memleaks

Conversation

@Karinon

@Karinon Karinon commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

(last one for today)

Fixes three memory leaks:

  • String variables: reading a string variable with getVariableArray or getSlicedVariableArray never freed the strings netCDF-C allocated, so memory grew with every read. They are now freed, as get() already did.
  • fromBlobLazy: if a file failed to open (e.g. it isn't a netCDF file), the worker kept running with no way to stop it. It is now terminated, as fromUrl already does.
  • Viewer: opening a new file or URL never closed the previous dataset, so each one left a worker running until the tab was closed. The previous dataset is now closed once the new one has loaded, and a dataset whose loading fails is closed too.

Tests

  • New tests check that repeated string reads don't grow the WASM heap.
  • The worker tests now check that the worker is stopped whenever opening fails, and when the dataset is closed.

@lazarusA
lazarusA merged commit 6b984c6 into main Oct 30, 2026
2 checks passed
@Karinon
Karinon deleted the fix-memleaks branch November 2, 2026 08:56
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