Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Task manager shows memory leak, but Heap snapshot doesn't

I run heavy JavaScript every 5 seconds and task manager shows constant increase of memory usage. However Heap snapshot doesn't. If I stop the script, memory is cleared after about half a minute two minutes.

UPDATE:

If I leave the script for a long time, the memory increases until the browser crashes. I also tried to run timeline test of chrome dev tools, and they also don't show the increase of memory usage, same as Heap snapshot. So I guess it's some kind of a leak, but I can't understand what is leaking.

Another thing which I can't confirm, as I can't install previous Chrome versions is that I don't remember this happening on previous (<24 Chrome versions). And IE10 runs this test without increasing memory. Could this be issue of new Chrome?

like image 231
zeroin Avatar asked Oct 21 '22 19:10

zeroin


1 Answers

Assuming you are referring to the Chrome Developer Tools, you might not be seeing the memory increase in the Heap snapshot, because the Heap snapshot profiler runs the Garbage Collector before the snapshot.

Seeing increased memory usage, especially during active processing, is quite normal. The garbage collector doesn't run unnecessarily. If your machine has memory to spare, it'll let the reserved memory grow. If you start pushing the limit of free memory, the collector should run. You should allow this to happen to see if it does.

Since you report that the memory goes down to it's original level after an idle period, that indicates that there is no memory leak, and the garbage collector is able to collect all allocated heap objects correctly.

However, IANAGE (I am not a Google engineer). I recommend reading the Heap Profiler documentation and the associated Memory 101 page for background.

like image 80
jevakallio Avatar answered Oct 24 '22 10:10

jevakallio