On the Profiles tab in DevTools select Record Heap Allocation . Wrap javascript to be evaluated when calling setTimeout() with a duration set enough time to click Start before the function passed to setTimeout is called; eg
<!DOCTYPE html> <html> <head> <script> t = 5; setTimeout(function() { (function test1() { var a = 123; function abc() { return a } abc(); }()); }, 10000) </script> </head> <body></body> </html>
When setTimeout is called a blue bar, it may be followed by a gray bar. Press Ctr+E to stop heap recording.
Select the blue or gray bar in the timeline graph. Select Containment from the drop-down menu, where the default option is Summary . Select
[1] :: (GC roots) @n
where n is a number.
Expand the selection by clicking the triangle to the left of [1] :: (GC roots) . Select [1] :: (GC roots) , view the displayed columns Distance , Shallow Size and Retained Size to select.
To test certain functions, highlight
[2] :: (External strings) @n
Where global variables and function calls should be listed that is, "t" and "setTimeout" on top of javascrip . Check the appropriate Distance , Shallow Size and Retained Size for choices.
guest271314
source share