Skip to content

High allocation volume and GC overhead in octane/universal/native on Hermes #1007

Closed

Description

@Josema

Hi, I’m working on a native WebGPU renderer for iOS using Hermes. I’ve integrated both Solid.js and Octane into my engine and noticed unexpectedly high JavaScript allocation and garbage collection overhead with octane/universal/native during simple updates.

This may be related to #981, although I haven’t confirmed whether the underlying cause is the same.

Asked Codex to created a standalone reproduction that runs both frameworks on Hermes using an in-memory host implementation, without my engine or any WebGPU rendering.

The test mounts 20 rows, each wrapped in four view components, and dispatches 2,000 simulated hover events. Each event selects a row by updating the active-row state. Both implementations produce the same host structure and property changes, and the test verifies that host nodes remain stable during updates and are cleaned up on unmount.

These are the results from one run:

Hermes 1.0.0, HBC 98, built in Release mode with the Hades garbage collector:

  • Tag: hermes-v250829098.0.10
  • Commit: becc964bd16002569bf74c4d8c190cfd2ad38985
Metric Octane 0.2.6 Solid 2.0.0-rc.6
Cumulative JS allocation 3.88 GB 5.82 MB
Sampled heap peak 112 MiB 8 MiB
Heap capacity after GC 108 MiB 8 MiB
Live JS after GC 54.10 MB 0.37 MB
Live JS after unmount 0.22 MB 0.23 MB
GC collections 1,364 6
Time in GC 33.26 s 0.18 ms
Elapsed time 36.37 s 40.00 ms

The 3.88 GB figure is cumulative allocation over the run, not simultaneous memory usage.

The main concerns are the allocation volume, the time spent in GC, and the live JS memory retained while the tree is still mounted. Memory drops substantially after unmount, so I’m not claiming a permanent memory leak.

I can share the test harness Codex prepared to reproduce this if that would help.

Activity

  1. trueadm commented on Sep 10, 2026

    @trueadm
    Collaborator

    We've made a bunch of fixes in this space, can you let me know if it still happens? Also any reproductions would be awesome

  2. Josema commented on Sep 10, 2026

    @Josema
    Author

    Better results for 0.2.7. Much faster, but still a huge amount of volume:

    Metric Octane 0.2.6 Solid 2.0.0-rc.6
    Cumulative JS allocation 3.88 GB 5.82 MB
    Sampled heap peak 112 MiB 8 MiB
    Heap capacity after GC 108 MiB 8 MiB
    Live JS after GC 54.10 MB 0.37 MB
    Live JS after unmount 0.22 MB 0.23 MB
    GC collections 1,364 6
    Time in GC 33.26 s 0.18 ms
    Elapsed time 36.37 s 40.00 ms

    Metric Octane 0.2.7 Solid 2.0.0-rc.6
    Cumulative JS allocation 2.35 GB 5.82 MB
    Sampled heap peak 88 MiB 8 MiB
    Heap capacity after GC 84 MiB 8 MiB
    Live JS after GC 53.45 MB 0.37 MB
    Live JS after unmount 0.22 MB 0.23 MB
    GC collections 629 6
    Time in GC 2.69 s 0.15 ms
    Elapsed time 4.59 s 39.00 ms

    I think it could be my implementation:
    https://github.com/Josema/octane-and-solid-core-memory-reproduction

    If you are not on mac, you will need to grab the right Hermes binary.

  3. domgan-oai commented on Sep 11, 2026

    @domgan-oai
    Contributor

    Can you try again now?

  4. Josema commented on Sep 11, 2026

    @Josema
    Author

    Can you try again now?

    Is there a new release? Latest is 0.2.7

    If so, how can I download it?

  5. trueadm commented on Sep 11, 2026

    @trueadm
    Collaborator

    Sorry I meant from latest master. I'll do a release later today to npm

  6. Josema commented on Sep 11, 2026

    @Josema
    Author

    Some improvements:

    Metric Octane 0.2.7 Solid 2.0.0-rc.6
    Cumulative JS allocation 2.35 GB 5.83 MB
    Sampled heap peak 92 MiB 8 MiB
    Heap capacity after GC 88 MiB 8 MiB
    Live JS after GC 53.45 MB 0.37 MB
    Live JS after unmount 0.22 MB 0.23 MB
    GC collections 669 6
    Time in GC 4.06 s 0.23 ms
    Elapsed time 6.51 s 53.00 ms

    Metric Octane 0.2.? Solid 2.0.0-rc.6
    Cumulative JS allocation 2.37 GB 5.83 MB
    Sampled heap peak 20 MiB 8 MiB
    Heap capacity after GC 8 MiB 8 MiB
    Live JS after GC 1.00 MB 0.37 MB
    Live JS after unmount 0.22 MB 0.23 MB
    GC collections 829 6
    Time in GC 123.21 ms 0.51 ms
    Elapsed time 2.35 s 81.00 ms
  7. domgan-oai commented on Sep 11, 2026

    @domgan-oai
    Contributor

    Correction: the reproduction should use Octane's public package exports. [email protected] is now published with the host binding added in #1044. Install it with npm install [email protected]; no source checkout, private path, or build step is needed.

    In your current octane.js, use these imports (alongside the existing universal functions):

    import {
      createUniversalRoot, defineUniversalComponent, universalPlan,
      universalValue, universalComponent, universalFor,
      universalHostBinding, useEffect,
    } from 'octane/universal/native';
    import { createScope } from 'octane/signals';

    Then change the selection state in mount and dispose it with the root:

    export function mount(host) {
      const driver = createDriver(host);
      const scope = createScope({ scopeKey: 'native-hover-test' });
      const selected$ = scope.signal$('selected', -1);
      // Keep the existing plans and View/Row components.
    
      const App = defineUniversalComponent(driver.id, () => {
        host.counts.appRenders++;
        const rows = universalFor(
          Array.from({ length: ROW_COUNT }, (_, index) => index),
          index => index,
          index => universalComponent(driver.id, Row, {
            id: index,
            active: universalHostBinding(selected$, value => value === index),
            onHover: () => {
              host.counts.eventCalls++;
              selected$.set(index);
            },
          }),
        );
        return universalValue(rootPlan, [rows]);
      });
    
      // Keep the existing root creation, render, dispatch, and flush code.
      // In the returned unmount() method, after root.unmount() and
      // root.flushPassiveTasks(), call scope.dispose().
    }

    I reproduced your latest commit cb2f30072 against Octane source commit 55a9aa3acd3f (0.2.8). Its unchanged root useState code allocated 2,365,148,472 B over 2,000 hovers and collected 829 times; Solid allocated 5,825,984 B and collected 6 times. App/Row/View ran 2,001/40,020/160,080 times on Octane versus 1/20/80 on Solid, because each root render supplies new row callbacks.

    Using the public API imports above with the host binding change, the same Hermes harness allocated 9,184,328 B for Octane versus 5,825,984 B for Solid, with 7 versus 6 GCs and an 8 MiB heap capacity for both. App/Row/View ran 1/20/80 times for both; 101 hosts, 3,999 native updates, 2,000 callbacks, 80 effect lifetimes, and teardown checks matched. These numbers were measured from the cited source commit; please rerun npm run hermes with the published package to record its exact result.

    This fixes the reproduction's allocation by expressing the update as a signal-backed host property. The original root useState path still rerenders its tree and remains expensive.

    Reproduction and measurements by an agent.

  8. Josema commented on Sep 11, 2026

    @Josema
    Author

    Yes, it works both in the isolated demo and in my WebGPU runtime.
    I assume this is a temporary workaround because it requires consumers to use a different API based on signals instead of plain useState.

    Metric Octane 0.2.8 Solid 2.0.0-rc.6
    Cumulative JS allocation 9.18 MB 5.83 MB
    Sampled heap peak 8 MiB 8 MiB
    Heap capacity after GC 8 MiB 8 MiB
    Live JS after GC 0.94 MB 0.37 MB
    Live JS after unmount 0.25 MB 0.23 MB
    GC collections 7 6
    Time in GC 0.51 ms 0.25 ms
    Elapsed time 19.00 ms 61.00 ms
  9. domgan-oai commented on Sep 11, 2026

    @domgan-oai
    Contributor

    With the universal renderer, there are no compiler optimizations applied – so useState isn't optimized and memoization doesn't occur like normal Octane. However, Octane does provide out-of-the-box signals as well, and it makes sense in this use-case.

  10. domgan-oai commented on Sep 19, 2026

    @domgan-oai
    Contributor

    Closing this as resolved for the reported native hover workload by #1044, first published in [email protected].

    That change releases superseded effect callbacks after accepted universal commits and adds the public universalHostBinding(source, select) API. Scoped signals can therefore update the affected host properties without rerendering the component tree. Your confirmation verified the result in both the isolated Hermes reproduction and your WebGPU runtime.

    The boundary remains explicit: the original hand-authored tree driven by root useState still rebuilds on updates and remains expensive. This change does not add automatic compiler memoization to that path. The signal-backed host-property route is the supported approach for this workload, as explained in the earlier maintainer response.

    I checked canonical main 47d5d1df: the host-binding API and accepted-effect cleanup remain present, with regression coverage in universal-host-bindings.test.ts and universal-effect-retention.test.ts. This follow-up is source/coverage verification and the reporter's existing confirmation; it is not a new Hermes measurement.

    Issue triage and this comment were assisted by an agent.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions