Skip to content

FSNode Memory Leak #17739

@ryan-weisenberger

Description

@ryan-weisenberger

Discussed in #17699

Originally posted by ryan-weisenberger August 22, 2022

% ./emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.19 (a5f7b1c9a1c74a830bebedc122d204800ce8dff9)
clang version 16.0.0 (https://github.com/llvm/llvm-project 30171e76f0e5ea8037bc4d1450dd3e12af4d9938)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Users/misha/wahoo/systm/crux_tools/submodules/emsdk/upstream/bin

We have a memory leak when calling our WASM through javascript generated by emscripten 3.1.19.

Our WASM converts a CSV file to a binary file in memory. Every time the converter finishes, it leaves behind a FSNode object. So after several hundred conversions, we get several hundred of these FSNode objects clogging up memory.

I'm using Node's v8.getHeapSnapshot() to take a heap snap before the conversions, after the conversions, and again after I have forced run the GC. I'm attaching those snapshots here.

The number of FSNode objects left over exactly matches the number of conversions. In this case, 978.

We've gone over the WASM code quite extensively, and cannot find a memory leak.

Any ideas what could cause this, and how to resolve it? If this looks like an emscripten problem, I can move this to Issues.

Chrome Memory Dev Tool

heapSnapshots.zip

Thanks,
Ryan

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions