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

oversized-object.js conclusion is incorrect #66

Closed fullstackren closed 1 year ago

fullstackren commented 1 year ago

I run the command(memlab run --scenario ~/memlab/scenarios/oversized-object.js)and find the data and graphics are correct, but the conclusion is incorrect(No leaks found, MemLab found 0 leak(s)).

04

JacksonGL commented 1 year ago

By default, large objects are not flagged as memory leaks since they could be cache created by the web app. However, if you want to identify large objects using MemLab, use the --trace-object-size-above option.

For example, you can set the flag to check objects larger than 1KB:

memlab run --scenario ~/memlab/scenarios/oversized-object.js --trace-object-size-above 1000

MemLab also supports self-defined leak detector with the leakFilter callback.

You can start with marking all objects allocated as leak and then refine the leak detector based on your app:

leakFilter(node, snapshot, leakedNodeIds) {
  return true;
}

Note: the callback could also be defined in the scenario file.

Please also check out this doc: https://facebook.github.io/memlab/docs/guides/guides-find-leaks