On Thu, 19 Nov 2026 00:04:17 GMT, David Holmes <[email protected]> wrote:

> This definitely seems an area that needs re-evaluation of the general design, 
> but this fix improves things. Thanks for clarifying the issues.

To preserve information discovered during this investigation, here are some 
concrete footprint numbers.

For one generated record-equality helper on Windows x64, defined without 
`STRONG` linkage, one dedicated `ClassLoaderData` contains one `InstanceKlass`.

| Component | Bytes |
|---|---:|
| CLD and supporting native bookkeeping, including the 160-byte CLD itself | 
≈680 |
| `InstanceKlass`, including its variable-sized tail | 576 |
| Additional non-class metadata | 1,000 |
| Unused capacity in the private Metaspace chunks | 472 |
| **Combined accounted footprint** | **≈2,728 bytes (2.66 KiB)** |

The Metaspace allocation consists of two fully committed 1 KiB chunks: one for 
class metadata and one for non-class metadata. Of the 2,048 bytes, 1,576 are 
used.

Roughly 680 bytes of CLD bookkeeping are allocated on the **native C heap, 
outside Metaspace**. That estimate comes from structure layouts examined in 
WinDbg and the source code, and is consistent with observed NMT reductions 
during class unloading.

`STRONG` linkage avoids dedicated CLD bookkeeping and places the helper’s 
metadata in the defining loader’s existing Metaspace arenas, shared with its 
other classes. The record-equality helper’s metadata still requires storage 
under either policy.

These figures describe this particular record-equality helper and build. They 
do not include Java heap objects, compiled code, allocation overhead, or shared 
infrastructure and are not an exact measurement of the incremental cost against 
`STRONG`.

Some useful relationships for this record-equality helper experiment:

- **Native CLD bookkeeping is about one-third of its Metaspace allocation:** 
680 / 2,048 ≈ 33%.
- **Native CLD bookkeeping accounts for about one-quarter of the combined 
footprint:** 680 / 2,728 ≈ 25%.
- **Metaspace utilization for this helper is about 77%:** 1,576 bytes used out 
of 2,048 bytes committed; the remaining 23% is free capacity.
- At this per-helper layout, **1,000 live helpers account for 2,048,000 bytes 
(2,000 KiB) of committed Metaspace chunk capacity**: 1,024,000 bytes in class 
Metaspace and 1,024,000 bytes in non-class Metaspace. **Their dedicated CLD 
bookkeeping adds about 680,000 bytes (664 KiB) on the native C heap, outside 
Metaspace.**

These ratios describe the components of this weakly linked record-equality 
helper’s footprint. They do not establish a 33% increase over `STRONG`: that 
comparison also depends on shared bookkeeping and Metaspace packing.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/33921#issuecomment-7002232440

Reply via email to