While looking for performance issues in a JavaScript library (rivets), i found that garbage collection occurs three to four times in a run, taking ~15% of execution time (using Chrome DevTools JS Profile).
There are at least 30 places where temporary functions / objects are created being potential candidates for the reason of the garbage collection.
I'd like to know if there's a way to find what functions are responsible for the allocation of the memory being garbage collected, so i can focus my performance tuning.
I recorded Heap Allocation TimeLine but it does not differentiate memory that was garbage collected and that still holds a reference (there's no gray bar as pointed in DevTools doc)
Also recorded Heap Allocation Profile without luck.
At
Profiles
tab atDevTools
selectRecord Heap Allocation
. Wrapjavascript
which should be evaluated within a call tosetTimeout()
with a duration set to enough time to clickStart
before function passed tosetTimeout
is called; for exampleWhen
setTimeout
is called a blue bar, possibly followed by a gray bar should appear at timeline. ClickCtr+E
to stop recording heap profile.Select blue or gray bar at timeline graph. Select
Containment
at dropdown menu where default option isSummary
. Selectwhere
n
is a number.Expand the selection by clicking triangle to left of
[1] :: (GC roots)
. Select an element of[1] :: (GC roots)
, review the displayedDistance
,Shallow Size
, andRetained Size
columns for the selection.To check specific functions, scroll to
to where global variables and function calls should be listed; i.e.g.,
"t"
and"setTimeout"
from abovejavascrip
. Check correspondingDistance
,Shallow Size
, andRetained Size
columns for the selection.