Skip to content

Performance timeline: PerformanceEntryKeyedBuffer never evicts entries (NativePerformance::reportMeasure → unbounded vector push_back) — retained across unmount and surface restart; +2.96 MB / 20 navigation cycles at 100% survival #60211

Open

Description

@john-stalvern

Description

The performance-timeline buffers grow without bound. Every performance.measure() call from JS (src/private/webapis/performance/Performance.js:62, cachedReportMeasure) reaches NativePerformance::reportMeasure (ReactCommon/react/nativemodule/webperformance/NativePerformance.cpp:158–166) → PerformanceEntryReporter::reportMeasure (ReactCommon/react/performance/timeline/PerformanceEntryReporter.cpp:206), which unconditionally appends the entry: measureBuffer_.add(entry) → PerformanceEntryKeyedBuffer::add → entryMap_[name].push_back(entry) (PerformanceEntryKeyedBuffer.cpp:13–24). There is no size cap, no eviction, and no lifecycle tie-in: the buffers (markBuffer_/measureBuffer_, PerformanceEntryReporter.h:120–121) belong to the process-lifetime PerformanceEntryReporter singleton, and the only drain path is an explicit JS performance.clearMarks()/clearMeasures() (PerformanceEntryReporter::clearEntries, PerformanceEntryReporter.cpp:168–179). Surface stop (stopSurface/unloadApp) leaves the timeline buffer intact.

Measured impact (react-native 0.83.6, bridgeless/Hermes, Android 17, dev-flavor debug build): over 20 push/pop navigation cycles of a plain content screen, the std::vector<std::variant<PerformanceMark, PerformanceMeasure, …>> behind PerformanceEntryKeyedBuffer::add grows +2.96 MB (2.935 MB in the sampled heapprofd diff; ~148 KB/cycle, ~15% of the app's per-cycle native slope) and is 100% retained through ReactDelegate.unloadApp()/stopSurface() + 4× forced Hermes GC — the only fully immortal allocation class in our accounting.

Trigger: on our rig the entries are produced by React's own renderer user-timing instrumentation — performance.measure(...) call sites ship in the dev/profiling renderer bundles (Libraries/Renderer/implementations/ReactFabric-dev.js, 17 call sites; ReactFabric-profiling.js; the prod bundle contains none) — so in a dev build every render appends entries that nothing ever removes. Any app or library calling performance.measure() without clearMeasures() accumulates the same way in any build type. The W3C performance-timeline model bounds stored entries (the maxBufferSize / dropped-entries mechanism browsers implement); this buffer has no such bound.

Environment

  • react-native 0.83.6, react 19.2.0, new architecture / bridgeless, Hermes, Android 17 (Pixel 8 Pro + emulator); measured on a dev-flavor debug build (dev renderer active)
  • class location: ReactCommon — react/performance/timeline/, react/nativemodule/webperformance/

Repro

Expected behavior

The timeline buffer should be bounded (per-name or total cap with drop-oldest + dropped-entries accounting, per the W3C timeline model) and/or cleared on surface stop / app unload. Process-long sessions that use the Performance API must not accumulate entries indefinitely.

Workaround

App-side mitigation exists: call performance.clearMeasures()/clearMarks() periodically (e.g. on navigation boundaries) to drain the buffers. (Unlike the shadow-graph class in #60210, which has no app-side mitigation.)

Separability

This class is disjoint from #60210's shadow-graph retention: different allocation sites (reporter buffer vs ShadowNode/props objects), different owner (PerformanceEntryReporter vs the wrapper-set/live-JS residue), and a different fix site (bound/trim the keyed buffer vs root-cause the wrapper residency). Fixing either does not affect the other.

Cross-references

Activity

  1. added
    Needs: Repro
    on Nov 22, 2026
  2. react-native-bot commented on Nov 22, 2026

    @react-native-bot
    Collaborator

    Warning

    Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:


    You can read more about about it on our website: How to report a bug.

  3. john-stalvern commented on Nov 22, 2026

    @john-stalvern
    Author

    Linked note: the companion reproducer PR #60215 (for #60210) exercises the same mount/unmount loop whose per-cycle native growth this timeline documents — it reproduces the dominant ShadowNodeWrapper retention (~70% of the heap delta). The PerformanceEntryKeyedBuffer growth described here (+2.96 MB/20 cycles, 100% immortal in our allocations analysis) is measured in the same session class but is not directly asserted by that PR; flagging that honestly rather than over-claiming coverage.

  4. added
    Needs: Attention
    and removed on Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionNeeds: Repro

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions