Can I get GC'd memory from dev tools?

I have a large application that I am debugging. I noticed the saw blade memory pattern which indicates frequent GC is happening.

To debug this, I am trying to find the contents of the GC'd memory. Is this possible in chrome with dev tools? I know I can take heap snapshots, but how can I ensure that this happens immediately after and after the GC? I know I can call a bunch of snapshot from code, but the same question.

+3


source to share


2 answers


There is no garbage collection information in DevTools yet. I requested this feature a while ago. You can "draw it" to indicate that you would also like to have it.


As far as snapshots are concerned, you cannot use them for your purpose. Before each shot is taken, all debris will be collected.

Are dead (inaccessible) objects included in snapshots?

Not. Only accessible objects are included in snapshots. Also, taking a snapshot always starts with a GC.



source


The best practice is to capture heap records (Profiles> Record Heap Allocations) and use snapshots to understand what objects are being created by the application. With this knowledge, you can try to identify objects that are on a short base (which cause the saw pattern).

By the way, if you are using requestAnimationFrame

, you should know that it is a saw pattern itself .

+1


source


With the "Heap type" write profile type, you can get information about the allocated objects.

In DevTools settings, you need to enable the "Write Heap Column Stack" option. See Screenshot.

Settings screenshot

After that, you need to record the "Write Heap" snapshot type. The writing process can slow down the page significantly because DevTools scans the js stack every time the page allocates an object. As a result, you will get a snapshot of the distribution information. In many cases DevTools can define the name of the object class. See Screenshot.



enter image description here

In the snapshot, you need to select "Distribution".

I think the information in the grid can help you solve your problem. In the screenshot you can see that there were 41k appropriations for the class, but only 12k of them are still alive. So 29k objects were rubbish. And even if you don't see the name of the object, you can go to the sources where the objects were selected.

+1


source







All Articles