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

Discussion: why the first page load uses much more heap memory even after GC #43

Closed Ckins closed 1 year ago

Ckins commented 1 year ago

Screen Shot 2022-10-11 at 3 50 41 PM Hi memlab team,

In the above screenshot, I repeat six times of an action and back.

There are 13 columns of heap memory dump. Why the first page load uses much more heap memory even after GC?

JacksonGL commented 1 year ago

@Ckins Somehow the web page allocates more memory in the initial page load. You might want to investigate the first heap snapshot (s1.heapsnapshot) in Chrome DevTool. As an alternative, try the following command after running the scenario:

memlab find-leaks --baseline $(memlab get-default-work-dir)/data/cur/s12.heapsnapshot --target $(memlab get-default-work-dir)/data/cur/s1.heapsnapshot --final $(memlab get-default-work-dir)/data/cur/s1.heapsnapshot --trace-all-objects