Unit testing javascript for a memory leak

According to MDN's docs on window.performance, Google Chrome has a non-standard extension (window.performance.memory) that gives access to values like usedJSHeapSize, totalJSHeapSize, jsHeapSizeLimit.

To get byte-level precision, you need to use the --enable-precise-memory-info flag.

For Garbage Collection, the only way I've found to force a browser to perform GC is with Chromium, with a special command flag. When you run this command:

chromium-browser --js-flags='--expose_gc'

you get access to the method window.gc(), which you can call to force GC.

This may open the possibility for testing memory usage in unit tests, for example.