facebook / memlab

A framework for finding JavaScript memory leaks and analyzing heap snapshots
https://facebook.github.io/memlab/
MIT License
4.35k stars 118 forks source link

Analyzing GCs #21

Closed fabiospampinato closed 1 year ago

fabiospampinato commented 1 year ago

Is it possible to use this tool to analyze why minor/major GCs happen? i.e. it'd be useful to get some kind of list of objects that get allocated and GC'd between the page load and when the final snapshot happen, so that one can try to trim it.

JacksonGL commented 1 year ago

MemLab analyzes heap snapshots. Taking heap snapshots automatically triggers GC in V8. So objects unreachable from GC roots are not visible to MemLab. If you are looking for opportunity to trim unnecessary allocation, perhaps one incomplete approach is to find duplicated objects and duplicated strings in heap snapshots.

fabiospampinato commented 1 year ago

I see it's just not what the tool was designed for, and maybe V8 doesn't provide the necessary tooling to really tackle on GC'd methodically. Thanks.

Open to ideas if anybody has any, checking for duplicates didn't seem to be particularly useful for what I was inspecting.