node-sass: Possible memory leaks

We are running constantly into out of memory errors with node-sass. Our scss setup is rather big and consists of 1076 scss files whereas 383 of them start with _.

We recently changed one of the scss underscore files to contain a map with all checksums for our images and this file is around 500kB big. What we did not expect is that node-sass/libsass memory usage will increase nearly by 100% which in our case means it jumped from 1.3GB to 2.1GB RAM usage.

All this memory is not freed after node-sass/libsass finished its work, and the watch tasks that run in the same node process after the full sass build still consumes > 2GB.

Even without our recent change 1.3GB is a massive amount of memory already and looks very much like memory leaks.

I profiled node-sass, but the profiler tells me that node only uses 30MB of memory, so the rest is probably coming from the native extension. I’m not a c++ developer and do not know how to profile and debug the native extension. I could provide more details if anyone tells me how to get them. Unfortunately I cannot share our scss codebase.

version info:

$ node-sass --version
node-sass       3.8.0   (Wrapper)       [JavaScript]
libsass         3.3.6   (Sass Compiler) [C/C++]

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 39 (25 by maintainers)

Most upvoted comments

In case it helps anyone isolate or understand the bug, I made a code demo that reproduces the issue on my machine: https://github.com/benallfree/node-sass-1669

We are aware of the memory issue. A patch will landing the next LibSass 3.5.beta. The LibSass 3.5.beta will land in Node Sass 5 betas in the new year.

This should be fixed in 4.2.0. Please let me know how y’all go

@mgreter If libsass isn’t thread-safe that may help explain why a bash concurrency (separate processes) works while webpack concurrency (separate threads?) doesn’t. But it doesn’t explain why node-sass 3.14 works while node-sass 4.x doesn’t.

I’m coming to this issue from https://github.com/jtangelder/sass-loader#333 where I discovered it.

@adampetrie See https://github.com/benallfree/node-sass-1669 for an example that works with node-sass 3.14.