2 ms·
The cost of a string array is paid on every GC phase. That array may/contains references so the gc has to check each element every time to check if anything cha
by yvdriess 1y ago
The cost of a string array is paid on every GC phase. That array may/contains references so the gc has to check each element every time to check if anything changed. An int array cannot contain references so it can be skipped.
edit: There are tricks to not traverse a compound object every time, but assume that at least one of the 80M objects in that giant array gets modified in between GC activations.
- Panzer04 1y agoThat seems like a huge burden, surely not? How often would a GC typically check for hanging references?
- yvdriess 1y agoThat's most of the work performed by a marking GC. How much a GC is of total cpu cost totally depends on the application, the GC implementation and the language. It's famously hard to measure what the memory management overhead is, GC in production is anywhere between 7-82% (Cai ISPASS2022). I measured about 19% geomean overhead in accurate simulation by ignoring instructions involved in GC/MM in python's pyperf benchmarks.