emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

memory leak associated with getFileDataAsRegularArray()

Open ericmandel opened this issue 7 years ago • 2 comments

In v1.38.5, I am seeing a large memory leak when repeatedly calling an astronomical reprojection routine (mProjectPP), which takes an two memory-based files as input and generates a new memory-based file as output. The output file is always unlink()'ed before each successive call. If I call mProjectPP 72 times, I see 70 retained chunks of 8.4Mb each, for a total leak of 580Mb, as shown below:

aggregate memory use indiv use

The previous output files were definitely removed (only the input file and final output file are still in the mem file system), as shown in this file list:

memfs file list

The mProjectPP code is basically clean according to Linux valgrind (a few thousand possibly leaked bytes), so I am at a loss about where to look for this problem. Any advice would be appreciated.

ericmandel avatar Jan 10 '19 16:01 ericmandel

FWIW, upgrading to v1.38.22 has no effect on this memory leak (although, subjectively, processing seems to be quite a bit faster -- thanks!)

ericmandel avatar Jan 10 '19 21:01 ericmandel

Ah, this is almost certainly caused by some process holding open the deleted files ... so not an Emscripten problem ...

ericmandel avatar Jan 11 '19 15:01 ericmandel