Repository navigation
Report wrapper cppgc allocations to V8 outside the no-GC scope - #7649
Merged
Merged
Conversation
attachWrapper() made both of its cppgc allocations, the CppgcShim and the slot wrapper V8 allocates for SetAlignedPointerInInternalField(), inside a cppgc NoGarbageCollectionScope. cppgc reports allocations to V8 only when GC is allowed, and nothing reports the buffered bytes when the scope closes. A loop that creates short-lived API objects therefore never told V8 the cppgc heap was growing, so V8 ran only minor GCs. Each wrapper takes two entries in V8's CppHeap pointer table, which only a major GC frees. Without one, the table filled after about 32M wrappers and the process aborted with "ExternalEntityTable:: AllocateEntry: allocation failed: process out of memory". In production this shows up in Durable Object alarms that call sql.exec() in a loop, and in loops of `new TextEncoder()`. Do both allocations before entering the scope. The scope only needs to cover creating the TracedReference and linking the wrapper to its shim, and neither allocates on the cppgc heap. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
|
LGTM! Moves wrapper allocations outside the no-GC scope and adds a major-GC regression test. Specialist findings not posted (1)
Reviewed commit: 6413f2b4 · github run |
erikcorry
approved these changes
Oct 7, 2026
This was referenced Oct 14, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
attachWrapper() made both of its cppgc allocations, the CppgcShim and the slot wrapper V8 allocates for SetAlignedPointerInInternalField(), inside a cppgc NoGarbageCollectionScope. cppgc reports allocations to V8 only when GC is allowed, and nothing reports the buffered bytes when the scope closes. A loop that creates short-lived API objects therefore never told V8 the cppgc heap was growing, so V8 ran only minor GCs.
Each wrapper takes two entries in V8's CppHeap pointer table, which only a major GC frees. Without one, the table filled after about 32M wrappers and the process aborted with "ExternalEntityTable:: AllocateEntry: allocation failed: process out of memory"
Do both allocations before entering the scope. The scope only needs to cover creating the TracedReference and linking the wrapper to its shim, and neither allocates on the cppgc heap.