Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to take a save a JS memory heap snapshot
Summary: Changelog: [internal] This adds support for taking JS memory heap snapshots from Fantom tests via `Fantom.saveJSMemoryHeapSnapshot`. This can be used in one-off tests to do memory analysis and determine the existence of leaks: ``` // Warm up Fantom.saveJSMemoryHeapSnapshot('/path/to/my/1.heapsnapshot'); // Do work Fantom.saveJSMemoryHeapSnapshot('/path/to/my/2.heapsnapshot'); // Clean up Fantom.saveJSMemoryHeapSnapshot('/path/to/my/3.heapsnapshot'); ``` Load these snapshots in Chrome and select "Objects allocated between 1 and 2" in the dropdown to see the potentially leaked objects. In the future we could introduce additional utilities to analyze the snapshots and do the detection automatically, e.g.: ``` // Warm up const baseline = Fantom.takeJSMemoryHeapSnapshot(); // Do work const before = Fantom.takeJSMemoryHeapSnapshot(); // Clean up const after = Fantom.takeJSMemoryHeapSnapshot(); const leaks = findMemoryLeaks(baseline, before, after); expect(leaks.sizeKB()).toBeLessThan(THRESHOLD); ``` Differential Revision: D68953788
- Loading branch information