facebook opened The initial texts of the tools memlab designed to analyze cuts of a state of dynamically distributed memory (heaps), determining the strategy for optimizing memory work and identifying memory leaks that arise when performing a code in JavaScript. Code open under the license mit.
Freimvork was created to analyze the causes of a large memory consumption when working with Web-sites and Web applications. For example, with the help of Memlab, a memory consumption was analyzed when using a new version of the Facebook.com site, which made it possible to identify leaks that led to the emergency completion of the browser on the client’s side due to the exhaustion of free memory.
The reasons for the memory leaks when performing a JavaScript code may be the presence of hidden links to objects, because of which the garbage collector cannot release the memory occupied by the object, unreasonable caching of values or the implementation of endless scrolling without displacing the old elements of the list. For example, in the following code, a memory leak occurs due to the object “OBJ”, since a link to NULL is set for it.
Var Obj = {}; console.log (Obj); Obj = null;
The main features of Memlab:
- Identification of memory leaks in the browser. Memlab allows you to automatically compare the casts of the state of dynamic memory, identify memory leaks and aggregate results.
- Object-oriented API for the bunch of heaps, which allows you to embody your own leaks to detect and implement systems for analyzing the casts of the state of the heap. The analysis of the heap for browsers based on the Chromium engine, as well as for the Node.js, Electron and Hermes.
- command line and API interface to search for possibilities for optimizing memory use.
- Assert system for node.js, which allows you to create unit tests and execute programs based on Node.js to create cuts of your own state, testing your memory or writing extended Assert Provers.
platforms, is supported.