I have the following piece of code:
public static void main(String[] args) {
int[] a = new int[Integer.MAX_VALUE / 4];
while (true);
}
The size of this array is supposed to be 2^29 and each integer occupies 4 bytes. The overall size of this array should be at least approximately 2GB. I run this code on my laptop with 16 Gig RAM.
I then run jstat and see the following output.
S0C 10752.0
S1C 10752.0
S0U 0.0
S1U 5421.8
EC 65536.0
EU 27194.8
OC 175104.0
OU 16.0
MC 14080.0
MU 13695.2
CCSC 1792.0
CCSU 1617.5
YGC 1
YGCT 0.006
FGC 0
FGCT 0.000
GCT 0.006
From the output we can determine that S1 occupies 5421.8KB and eden occupies 27194.8KB. Is there some kind of optimization had been performed so that all entries map to the same value in the memory?