Skip to content

fix: Memory leak in sync modifiers - missing cleanup of name arrays #183

Description

@andeplane

Problem

The sync modifiers (synccomputesmodifier.ts, syncfixesmodifier.ts, syncvariablesmodifier.ts) retrieve name arrays from WASM but never delete them, causing memory leaks.

Current Behavior

In all three sync modifiers:

  • computeNames, fixNames, or variableNames are obtained via getComputeNames(), getFixNames(), or getVariableNames()
  • These CPPArray<string> objects are used in loops but never cleaned up with .delete()
  • This causes WASM memory to accumulate over time

Expected Behavior

After the loop completes processing all names, the array wrapper should be deleted to free WASM memory.

Files to Modify

  • src/modifiers/synccomputesmodifier.ts - Add computeNames.delete() after line 123
  • src/modifiers/syncfixesmodifier.ts - Add fixNames.delete() after line 118
  • src/modifiers/syncvariablesmodifier.ts - Add variableNames.delete() after line 120

Solution

Add .delete() calls after each loop completes, similar to how data1DNamesWrapper, lmpData, and data1DVector are already being deleted elsewhere in the code.

Related

Part of modifier class improvements to fix memory leaks and reduce code duplication.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions