Skip to content

Commit 4ee326f

Browse files
rubennortefacebook-github-bot
authored andcommitted
Add documentation for JS memory profiler in Fantom (facebook#53226)
Summary: Pull Request resolved: facebook#53226 Changelog: [internal] This adds documentation about how to take JS memory heap snapshots in Fantom. Reviewed By: lenaic Differential Revision: D80090283 fbshipit-source-id: 04f66a62aa756d1020b8d8ef6fc0ea7e68341710
1 parent 90804fd commit 4ee326f

File tree

1 file changed

+38
-0
lines changed
  • private/react-native-fantom/__docs__

1 file changed

+38
-0
lines changed

private/react-native-fantom/__docs__/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,44 @@ trace will be created for each variant.
244244
You can analyze the traces loading them in Chrome DevTools directly. You can
245245
also open them in VS Code, which provides a built-in extension for analysis.
246246

247+
#### JS memory profiler
248+
249+
You can manually take JS memory heap snapshots during test execution using
250+
`Fantom.takeJSMemoryHeapSnapshot()`. E.g.:
251+
252+
```javascript
253+
// Using the 3 snapshot method to detect memory leaks:
254+
255+
// Warm up
256+
renderView();
257+
destroyView();
258+
259+
// #1
260+
Fantom.takeJSMemoryHeapSnapshot();
261+
262+
renderView();
263+
264+
// #2
265+
Fantom.takeJSMemoryHeapSnapshot();
266+
267+
destroyView();
268+
269+
// #3
270+
Fantom.takeJSMemoryHeapSnapshot();
271+
272+
// See the objects allocated between #1 and #2 that still exist in #3.
273+
```
274+
275+
This function will force a garbage collection pass, take a snapshot of the JS
276+
memory heap and print a message indicating where it was saved. E.g.:
277+
278+
```text
279+
💾 JS heap snapshot saved to /path/to/react-native/private/react-native-fantom/.out/js-heap-snapshots/View-itest.js-2025-08-12T14:29:25.987Z.heapsnapshot
280+
```
281+
282+
You can have multiple calls to `Fantom.takeJSMemoryHeapSnapshot()` in your test,
283+
and each one will create a different file.
284+
247285
### FAQ
248286

249287
#### How is this different from Jest tests?

0 commit comments

Comments
 (0)