11

I am having some memory leak in my code. so i took memory snapshot using heapdump nodemodule. using heapdump i have fixed something then its fine. But why string buffer size is still too high and its keep on increasing ?

I have attached screen shot of the memory heapdump for my component. the heapdump file size is 139MB so i cant attach here. i dont know what other information you guys need to help on this...

String memory list

Overall memory list

balaphp
  • 1,306
  • 5
  • 20
  • 40
  • I'm having this exact same issue, did you ever get it resolved? – iksose Jan 22 '15 at 16:32
  • Not yet completely but getting closer. will post once i got complete solution. – balaphp Jan 28 '15 at 09:55
  • Those strings in the screenshot are the functions that enclose all files you `require()`. Since they are anonymous, every required module gets its own. I wonder, however, why they do not get released. What Node.js version are you using? Are you using native JS or some compile-to-js language (CoffeeScript, TypeScript etc.)? – Robert Rossmann Jun 03 '15 at 18:40
  • 1
    Are you doing require() in a loop? – TomG Jun 15 '15 at 14:23
  • @TomG No i am not doing anything like that... – balaphp Jun 15 '15 at 15:07
  • the memory leak solution is null your all objects and array at end of function. use process.memoryUsage() and check the heapused value. If the value is not reducing then u r having some problem. dont consider RSS value – balaphp Jul 23 '15 at 12:12
  • Also, it may be helpful to know what version of nodejs you are using... Have you also consider node-inspector? – doktoroblivion Aug 29 '15 at 22:38
  • I'm having this same issue, you can see here. I'm using Babel.. Amy thoughts? http://stackoverflow.com/questions/36628540/why-is-node-require-cache-filling-up-and-leaking – wprater Apr 15 '16 at 15:26

1 Answers1

1

The memwatch module might help provide some more insight. It will allow you to subscribe to leak events

memwatch.on('leak', function(info) { 
console.error('Memory leak detected: ', info); 
});

Have a read of this tutorial which does a great job of explaining how to detect the reasons for memory leaks in node.

Philip O'Brien
  • 4,146
  • 10
  • 46
  • 96