JVM Tutorials - Herong's Tutorial Examples - Version 4.23, by Dr. Herong Yang
640/400/40MB Test on HotSpot Client 1.7
This section provides a tutorial example on running GCTest2.java on HotSpot Client JVM 1.7.0_45 with 640MB memory limit and a 400MB base plus 40MB fluctuating memory usage with object size of 1.25MB.
Here is my first test with GCTest2.java with HotSpot Client 1.7.0_45 and maximum memory of 640MB on my Windows 7 system:
>\Progra~1\java\jdk1.7.0_45\bin\javac GCTest2.java >\Progra~1\java\jdk1.7.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 182776 450760 28% 450560 409600 40960 200 3 633536 141817 491719 22% 450560 409600 40960 41159 4 633536 100857 532679 15% 491520 409600 81920 41159 5 633536 59896 573640 9% 532480 409600 122880 41160 6 633536 18936 614600 2% 573440 409600 163840 41160 7 633536 7417 626119 1% 450560 409600 40960 175559 8 633536 141829 491707 22% 450560 409600 40960 41147 9 633536 100868 532668 15% 491520 409600 81920 41148 10 633536 59908 573628 9% 532480 409600 122880 41148 11 633536 18939 614597 2% 573440 409600 163840 41157 12 633536 18944 614592 2% 450560 409600 40960 164032 14 633536 141833 491703 22% 450560 409600 40960 41143 15 633536 100869 532667 15% 491520 409600 81920 41147 16 633536 59908 573628 9% 532480 409600 122880 41148 17 633536 18944 614592 2% 573440 409600 163840 41152 18 633536 18947 614589 2% 450560 409600 40960 164029 19 633536 141834 491702 22% 449280 409600 39680 42422 20 633536 100872 532664 15% 490240 409600 80640 42424 21 633536 59907 573629 9% 531200 409600 121600 42429 22 633536 18945 614591 2% 572160 409600 162560 42431 23 633536 182796 450740 28% 449280 409600 39680 1460 25 633536 141833 491703 22% 490240 409600 80640 1463 26 633536 100871 532665 15% 531200 409600 121600 1465 27 633536 59906 573630 9% 572160 409600 162560 1470 28 633536 18944 614592 2% 613120 409600 203520 1472 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)
I am very surprised to see OutOfMemoryError exception. Let's review the output to understand what happened in the JVM. Note that the output was reformatted with white spaces.
I repeated this test many times. "OutOfMemoryError" exception occured about 70% of the time.
Conclusion, HotSpot Client JVM 1.7.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.
Last update: 2014.
Table of Contents
Downloading and Installing JDK 1.8.0 on Windows
Downloading and Installing JDK 1.7.0 on Windows
java.lang.Runtime Class - The JVM Instance
java.lang.System Class - The Operating System
ClassLoader Class - Class Loaders
Class Class - Class Reflections
JRockit JVM 28.2.7 by Oracle Corporation
Memory Management and Garbage Collectors
GCTest2.java - Garbage Collection Test Program
►640/400/40MB Test on HotSpot Client 1.7
640/400/40MB Test on HotSpot Client 1.6
640/400/40MB Test on JRockit 28.2
441/400/40MB Test on JRockit 28.2
1076/800/80MB Test on HotSpot Client 1.7
1076/800/80MB Test on HotSpot Client 1.6
1076/800/80MB Test on JRockit 28.2
JVM Stack, Frame and Stack Overflow
Thread Testing Program and Result
CPU Impact of Multi-Thread Applications
I/O Impact of Multi-Thread Applications
Micro Benchmark Runner and JVM Options
Micro Benchmark Tests on "int" Operations
Micro Benchmark Tests on "long" Operations
Micro Benchmark Tests in JIT Compilation Mode