I'm trying to measure the memory usage of my site with the memory section of the Timeline tab in Chrome developer tools.
At various points I hit the garbage can button to force a garbage collection. The problem is the graph suddenly goes limp, and stops all measurements. Eventually, after I start doing other things it starts measuring again, but I never see the exact spot / value on the graph where I hit the GC button.
The first two downward slopes start immediately after I hit the garbage collect button, and they later just sort of connect to a new current value after I've been working.
Question is:
Is there a way to force this graph to keep or start measuring? Alternately, is there a simple way in JavaScript to console.log
the current memory usage value?
As a related question, is there a way to point to a spot on the graph and see the exact memory usage at that point?
I'm trying to measure the memory usage of my site with the memory section of the Timeline tab in Chrome developer tools.
At various points I hit the garbage can button to force a garbage collection. The problem is the graph suddenly goes limp, and stops all measurements. Eventually, after I start doing other things it starts measuring again, but I never see the exact spot / value on the graph where I hit the GC button.
The first two downward slopes start immediately after I hit the garbage collect button, and they later just sort of connect to a new current value after I've been working.
Question is:
Is there a way to force this graph to keep or start measuring? Alternately, is there a simple way in JavaScript to console.log
the current memory usage value?
As a related question, is there a way to point to a spot on the graph and see the exact memory usage at that point?
Share Improve this question asked Aug 16, 2013 at 21:40 Adam RackisAdam Rackis 83.4k57 gold badges278 silver badges400 bronze badges 4-
1
From the console, you can get the current memory usage with
performance.memory
. – bfavaretto Commented Aug 16, 2013 at 21:48 - Nice - thanks. Would you mind adding that as an answer, @bfavaretto – Adam Rackis Commented Aug 16, 2013 at 21:50
- @bfavaretto - also, any idea why performance.memory is giving me all zeros? – Adam Rackis Commented Aug 16, 2013 at 21:55
-
No idea, here is what it gives me for this page:
MemoryInfo {jsHeapSizeLimit: 793000000, usedJSHeapSize: 10000000, totalJSHeapSize: 17100000}
. I actually don't know much about it, or about the Timeline tool. That's why I just added a ment, there probably is a better answer... – bfavaretto Commented Aug 16, 2013 at 21:59
1 Answer
Reset to default 5Timeline records events that happen on the renderer side. Each event record also has "memory usage" field. Timeline uses these numbers for the memory graph. So if there are no events for a time interval then memory graph shows nothing.
From the other side if renderer does nothing then the memory size doesn't change.
If you absolutely sure that you need memory data then you can setup a timer that does nothing.
For example you can execute in console setInterval(function() {}, 1000);
In that case Timeline will get timer event with the memory usage data and will draw the memory graph.