A server-rendered request can allocate several megabytes of short-lived objects, fill V8’s young generation, and trigger garbage collection many times per second. The heap is the memory region where those objects live; collection reclaims unreachable objects so their memory can be reused. section 9.2.1 section 2.2.2
V8 organizes heap storage into progressively specialized regions:
- Pages divide the heap into fixed-size blocks, typically around 256 KB, and may contain unrelated heap objects. section 2.2.2
- The young generation uses two semi-spaces, with one active and the other reserved as the next copying target. section 9.2.1
- Objects surviving two scavenges are promoted to the old generation, where collection is more expensive. section 9.2.1
- Oversized allocations bypass the young generation and enter the Large Object Space, where each receives a dedicated page. section 2.2.2 section 9.2.1
A string changes storage region
V8 stores strings as heap objects. A string smaller than 128 KB stays on a regular page; a larger string goes to the Large Object Space. The ECMAScript limit is abstractly enormous, but the runtime imposes practical implementation limits. section 2.2.2
Figure 9.3 V8 divides its heap into distinct spaces. The young generation contains two semi-spaces (from-space and to-space), only one active at a time. Objects that survive two scavenges are promoted to the old generation. Allocations too large for the young generation go directly to the large object space.
Use the heap-layout figure to trace semi-spaces, promotion after scavenges, and direct large-object allocation. section 9.2.1










