Hermes memory: JS heap is only part of the story
Prerequisites: 01-hermes-pipeline, 05-hermes-jsi
Two memory domains
Mental model synthesis
Hermes owns JS values and reclaims unreachable JS objects. A JSI host object can reference a separate native resource; a JS heap snapshot alone cannot account for every native allocation. React Native DevTools can inspect the JS heap, while platform tools are needed beneath it.
[S04] [S13] [S14]Worked diagnosis synthesis
A gallery grows 20 MB after each open/close. Compare JS heap snapshots, Android Studio/Xcode native memory, and the number of retained image contexts. A stable JS heap plus growing native allocation points toward the native resource path, not proof of a GC defect.
[S13] [S14]Engineering decision synthesis
Define resource release at unmount, module destruction and cancellation. Avoid retaining callbacks and long-lived handles without an owner. Measure steady-state after repeated navigation.
[S12] [S13] [S14]Failure mode and improvement synthesis
Calling GC manually is not a substitute for fixing a retained reference. Trace object ownership and eliminate the root; rerun the same loop to establish whether memory plateaus.
[S13] [S14]Check yourself: Would a flat JS heap rule out a native image leak?
No. Native buffers and platform views can grow outside the JS heap.