Based mostly on the diff outcomes, MemLab builds an inventory of potential reminiscence leaks and for every of them generates a retainer traces, i.e. an object reference chain from the rubbish collector roots. By inspecting the retainer traces, you may visualize which references ought to have been set to
null for correct assortment. Moreover, to scale back the quantity of data that must be analyzed, MemLab is ready to cluster leaked objects based mostly on the similarity of their retainer traces and present them for every cluster as a substitute of for every potential leak.
log an object to Chrome console, Chrome will take a hidden reference to it that can stop it from being collected. Different circumstances the place you may have leaks or unbound reminiscence development are associated to the unintentional use of world variables, to forgotten timers or callbacks, and to out-of-DOM references, says auth0 engineer Sebastian Peyrott.
Fb has been utilizing MemLab for just a few years, which allowed them to scale back OOM crashes on Fb.com by 50 p.c within the first half of 2021. Additionally they used the heap graph view and the heap evaluation API to additional enhance reminiscence behaviour of React Fibers and to enhance Relay reminiscence interning.
MemLab is open source and might be put in working
npm i -g memlab.