Java 8 GC Tutorials - Herong's Tutorial Examples - v1.03, by Dr. Herong Yang
Archived: 640/400/40MB Test on HotSpot Client 1.6
This section provides a tutorial example on running GCTest2.java on HotSpot Client JVM 1.6.0_45 with 640MB memory limit and a 400MB base plus 40MB fluctuating memory usage with object size of 1.25MB.
As a comparison, I ran GCTest2.java with the same parameters on HotSpot Client 1.6.0_45 my Windows 7 system:
herong> \Progra~1\java\jdk1.6.0_45\bin\javac GCTest2.java
herong> \Progra~1\java\jdk1.6.0_45\bin\java -Xmx640m GCTest2
Test parameters:
Object size: 1280KB
Initial objects and data size: 320, 409600KB
Added objects and data size: 32, 40960KB
Time Total Free Used Free Total Act. Dead Over
sec. Mem. Mem. Mem. %. Obj. Obj. Obj. Head
1 633536 182807 450729 28% 450560 409600 40960 169
2 633536 141849 491687 22% 450560 409600 40960 41127
3 633536 100888 532648 15% 491520 409600 81920 41128
4 633536 59928 573608 9% 532480 409600 122880 41128
5 633536 18967 614569 2% 573440 409600 163840 41129
7 633536 7448 626088 1% 450560 409600 40960 175528
8 633536 141860 491676 22% 450560 409600 40960 41116
9 633536 100900 532636 15% 491520 409600 81920 41116
10 633536 59939 573597 9% 532480 409600 122880 41117
11 633536 18971 614565 2% 573440 409600 163840 41125
12 633536 18976 614560 2% 450560 409600 40960 164000
13 633536 141864 491672 22% 450560 409600 40960 41112
14 633536 100900 532636 15% 491520 409600 81920 41116
15 633536 59940 573596 9% 532480 409600 122880 41116
16 633536 18976 614560 2% 573440 409600 163840 41120
18 633536 18979 614557 2% 450560 409600 40960 163997
19 633536 141866 491670 22% 450560 409600 40960 41110
20 633536 100903 532633 15% 491520 409600 81920 41113
21 633536 59939 573597 9% 532480 409600 122880 41117
22 633536 18976 614560 2% 573440 409600 163840 41120
23 633536 182827 450709 28% 450560 409600 40960 149
24 633536 141865 491671 22% 491520 409600 81920 151
25 633536 100902 532634 15% 532480 409600 122880 154
26 633536 59938 573598 9% 573440 409600 163840 158
27 633536 18975 614561 2% 614400 409600 204800 161
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at GCTest2$MyObject.<init>(GCTest2.java:70)
at GCTest2.myTest(GCTest2.java:37)
at GCTest2.main(GCTest2.java:22)
Conclusion, HotSpot Client JVM 1.6.0_45 requires more than 640MB to run a program that has a 400MB base memory usage plus 40MB fluctuating memory usage with object size of 1.25MB. Basically, the JVM requires more than 200MB to manage dead objects and other system tasks.
Table of Contents
Heap Memory Area and Size Control
JVM Garbage Collection Logging
Introduction of Garbage Collectors
Serial Collector - "+XX:+UseSerialGC"
Parallel Collector - "+XX:+UseParallelGC"
Concurrent Mark-Sweep (CMS) Collector - "+XX:+UseConcMarkSweepGC"
Garbage First (G1) Collector - "+XX:+UseG1GC"
Object References and Garbage Collection
Garbage Collection Performance Test Program
Performance Tests on Serial Collector
Performance Tests on Parallel collector
Performance Tests on Concurrent collector
Performance Tests on G1 collector
Garbage Collection Performance Test Summary
Archived: GCTest2.java - Garbage Collection Test Program
Archived: 640/400/40MB Test on HotSpot Client 1.7
►Archived: 640/400/40MB Test on HotSpot Client 1.6
Archived: 640/400/40MB Test on JRockit 28.2
Archived: 441/400/40MB Test on JRockit 28.2
Archived: 1076/800/80MB Test on HotSpot Client 1.7
Archived: 1076/800/80MB Test on HotSpot Client 1.6