You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
High allocation volume and GC overhead in octane/universal/native on Hermes #1007
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.
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):
Then change the selection state in mount and dispose it with the root:
exportfunctionmount(host){constdriver=createDriver(host);constscope=createScope({scopeKey: 'native-hover-test'});constselected$=scope.signal$('selected',-1);// Keep the existing plans and View/Row components.constApp=defineUniversalComponent(driver.id,()=>{host.counts.appRenders++;constrows=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);},}),);returnuniversalValue(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.
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.
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.
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.
Activity
trueadm commentedon Sep 10, 2026
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
Josema commentedon Sep 10, 2026
Better results for 0.2.7. Much faster, but still a huge amount of volume:
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.
domgan-oai commentedon Sep 11, 2026
Can you try again now?
Josema commentedon Sep 11, 2026
Is there a new release? Latest is 0.2.7
If so, how can I download it?
trueadm commentedon Sep 11, 2026
Sorry I meant from latest master. I'll do a release later today to npm
Josema commentedon Sep 11, 2026
Some improvements:
domgan-oai commentedon Sep 11, 2026
Correction: the reproduction should use Octane's public package exports.
[email protected]is now published with the host binding added in #1044. Install it withnpm 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):Then change the selection state in
mountand dispose it with the root:I reproduced your latest commit
cb2f30072against Octane source commit55a9aa3acd3f(0.2.8). Its unchanged rootuseStatecode 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 hermeswith 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
useStatepath still rerenders its tree and remains expensive.Reproduction and measurements by an agent.
Josema commentedon Sep 11, 2026
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.
domgan-oai commentedon Sep 11, 2026
With the universal renderer, there are no compiler optimizations applied – so
useStateisn'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.domgan-oai commentedon Sep 19, 2026
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
useStatestill 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 inuniversal-host-bindings.test.tsanduniversal-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.