Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding Chrome Heap Profile

I am trying to diagnose an SPA. I took two snapshots, one right after another, while the app was idle. Here is a snapshot below. As you can see, the shallow size of these objects is huge. But I have no idea what they are, or where in the code they come from. The (compiled code) does not make sense to me, nor do deoptimization_data or relocation_info.

Does anyone know how to use this information to actually track down leaks in a sizable app?

enter image description here

like image 391
Daniel Williams Avatar asked Dec 20 '13 06:12

Daniel Williams


People also ask

How do I check my Chrome heap memory?

As the name implies, heap snapshots show you how memory is distributed among your page's JS objects and DOM nodes at the point of time of the snapshot. To create a snapshot, open DevTools and go to the Profiles panel, select the Take Heap Snapshot radio button, and then press the Take Snapshot button.

What is the purpose of taking a heap snapshot?

Use it to compare two (or more) memory snapshots from before and after an operation. Inspecting the delta in freed memory and reference count lets you confirm the presence and cause of a memory leak. Containment view. Allows exploration of heap contents.

How do I run a memory profiling in Chrome?

To begin using the allocation profiler: Make sure you have the latest Chrome Canary. Open the Developer Tools and click on the gear icon in the lower right. Now, open the Profiler panel, you should see a profile called "Record Heap Allocations"

Does Chrome have a memory leak?

Google Chrome is one of the popular web browsers and Chrome memory leak is one of the common issues. Today we will talk about this problem on the MiniTool website. If you find there are many tabs of Chrome in Task Manager and Chrome uses much memory, follow these solutions below to easily fix the issue.


1 Answers

Please use the technique described here: Tool to track down JavaScript memory leak

Javacript engine in Chrome, called v8, does number of things for executing scripts fast. Actually it compiles on the fly all your js code (JIT). The compiled code may become unnecessary if you removes all the calls and references to it. ie you may have an element in the DOM tree with event listener and at some moment you may remove this element from the DOM tree. As a result the code for the event listener will become unnecessary and v8 should be able to delete that code. So, v8 keeps the compiled code in the same managed heap as for your objects, arrays, strings etc.

When you are looking into the heap snapshot you see everything that was in the heap including everything related to the code like code relocation info, deoptimization data, arrays with line-ends, the script texts etc.

like image 64
loislo Avatar answered Oct 20 '22 16:10

loislo