Skip to content

Opaque handle memory leak in host stores #346

@aallan

Description

@aallan

The _map_store, _set_store, and _decimal_store dicts in vera/codegen/api.py are append-only — entries are never deleted during execution. Long-running programs that create many transient Maps/Sets/Decimals will accumulate unbounded Python-side memory.

Impact

Each map_new(), set_new(), decimal_from_int() etc. allocates a new handle that persists for the entire execute() call. Functional operations like map_insert() create new handles without releasing old ones.

Current behaviour

Handles are local variables inside execute() and are freed by Python GC when execute() returns. No cross-call leakage. But within a single execution, memory grows monotonically.

Possible fix

A handle-refcounting or handle-finalizer scheme that frees host-side data when the WASM GC collects the ADT containing the handle. This would require coordination between the WASM mark-sweep collector and the host stores.

Affects: Map, Set, Decimal, and any future opaque handle types (Json).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcodegenCode generation backendduplicateThis issue or pull request already exists

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions