Open ilyazub opened 7 years ago
Wow, great issue content. Thanks!
Would it be possible to get the error-prone images as well?
Unfortunately, it doesn't depend on images. There are 81K+ sources for 800+ destination sprites in the project I'm working on, and the issue reproduces with any combination of images.
Anyway, images were used in the script above: sprite_images.tar.gz
I've run that sample script through valgrind
and examined output
output.tar.gz with massif-visualizer
valgrind --tool=massif node ./test.js
Here is a screenshot of the heap usage of C++ calls. I haven't understand yet how to get JS stack from valgrind
output. It shows that leak is near to zlib
usage.
And run Valgrind's leak-detector shows that leaks are near to node::ZCtx::New(v8::FunctionCallbackInfo<v8::Value> const&)
and node::ZCtx::Init(v8::FunctionCallbackInfo<v8::Value> const&)
valgrind --leak-check=full --show-leak-kinds=all node ./test.js
Full valgrind
output: valgrind_leaks.log.tar.gz
Now I'm trying to get JS stack from the valgrind
trace. Probably, it should be done with lldb or something similar.
Cool, thanks for digging into this so much. I don't have time over the next few days to take a look at this. My recommendation is to isolate which of the libraries in get-pixels
is causing the issue by using only JPGs or only PNGs and seeing when it occurs
Also, it looks like global.gc()
is being run every 50 iterations. Shouldn't it be run every iteration and memory usage be dumped after that? We want to verify a leak, not worry about uncollected variables
Also, we should probably be using a callback function instead of a for
loop. With this current variant, we are running all of the spritesmith
actions in parallel instead of in series. I imagine we want to see the leak grow over time
Spritesmith#processImages
not freeing memory over time when creating multiple sprite images.vinyl
files withBuffer
in contents and plain file paths results in the same memory usage.Related issue in
spritesmith
: Ensighten/spritesmith#72I'm asking for help in leak detection in modules used in
pixelsmith
.Simplified script to reproduce an issue
Memory usage
4 heap snapshots were captured over time shows huge amount of
system/JSArrayBufferData
allocations.I'm assuming that images are leaking in streams of
get-pixels
,ndarray
orpngjs-nozlib
modules, being used inprocess.nextTick()
insmith.js
.canvassmith
doesn't result in memory leak, so it's an issue ofpixelsmith
Heap snapshots with
canvassmith
: canvassmith_heapsnapshots.tar.gzPackages versions
spritesmith@3.1.1
vinyl@2.1.0
pixelsmith@2.1.1
canvassmith@1.1.0