JVM Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.10

GC Test - JDK 1.6.0 vs. JDK 1.4.0

This section provides a tutorial example on testing garbage collection by comparing performances between JDK 1.6.0 and JDK 1.4.0

Comparison - JDK 1.6.0 vs. 1.4.0

After installing JDK 6u2 on a Windows XP system, I repeated the same tests to see how JDK 1.6.0 behaves:

java -Xms2m -Xmx8m GCTest 16 1 > tail_16_01.out
java -Xms2m -Xmx8m GCTest 16 8 > tail_16_08.out
java -Xms2m -Xmx8m GCTest 16 16 > tail_16_16.out
java -Xms2m -Xmx8m GCTest 16 24 > tail_16_24.out

Test "java -Xms2m -Xmx8m GCTest 16 24" gave me an OutOfMemoryError similar to JDK 1.4.0 as shown below:

Time   Total   Free   Free   Total   Act.   Dead   Over
sec.   Mem.    Mem.   Per.   Obj.    Obj.   Obj.   Head

0       1984   1772    89%       0      0      0    212
0       1984   1643    82%     128    128      0    213
1       1984   1515    76%     256    256      0    213
1       1984   1387    69%     384    384      0    213
2       1984   1259    63%     512    512      0    213
2       1984   1131    57%     640    640      0    213
3       1984   1107    55%     768    640    128    109
3       1984   1098    55%     896    768    128    -10
4       1984    960    48%     896    896      0    128
4       1984    832    41%    1024   1024      0    128
5       1984    704    35%    1152   1152      0    128
5       1984    576    29%    1280   1280      0    128
6       1984    448    22%    1408   1408      0    128
6       3488   1837    52%    1536   1536      0    115
7       3488   1702    48%    1664   1664      0    122
7       3488   1574    45%    1920   1792    128     -6
8       3488   1446    41%    1920   1920      0    122
8       3488   1318    37%    2048   2048      0    122
9       3488   1190    34%    2176   2176      0    122
9       3488    938    26%    2432   2432      0    118
10      3488    810    23%    2560   2560      0    118
10      3488    682    19%    2688   2688      0    118
11      3488    554    15%    2816   2816      0    118
11      3488    426    12%    2944   2944      0    118
12      6052   2870    47%    3072   2944    128    110
12      6052   2736    45%    3200   3200      0    116
13      6052   2608    43%    3328   3328      0    116
13      6052   2480    40%    3456   3456      0    116
14      6052   2352    38%    3584   3584      0    116
14      6052   2224    36%    3712   3712      0    116
15      6052   2102    34%    3840   3712    128    110
15      6052   1969    32%    3968   3968      0    115
16      6052   1969    32%    3968   3968      0    115
16      6052   1841    30%    4096   4096      0    115
17      6052   1713    28%    4224   4224      0    115
17      6052   1583    26%    4352   4352      0    117
18      6052   1455    24%    4608   4480    128    -11
18      6052   1331    21%    4608   4608      0    113
19      6052   1201    19%    4736   4736      0    115
19      6052    945    15%    4992   4992      0    115
20      6052    817    13%    5120   5120      0    115
20      6052    815    13%    5120   5120      0    117
21      6052    815    13%    5120   4864    256    117
21      6052    815    13%    5120   4736    384    117
22      6052    815    13%    5120   4608    512    117
22      6052    813    13%    5120   4480    640    119
23      6052    813    13%    5120   4352    768    119
23      6052    813    13%    5120   4224    896    119
24      6052    813    13%    5120   4096   1024    119
24      6052    811    13%    5120   3968   1152    121
25      6052    811    13%    5120   3840   1280    121
25      6052    811    13%    5120   3712   1408    121
26      6052    811    13%    5120   3584   1536    121
26      6052    809    13%    5120   3456   1664    123
27      6052    809    13%    5120   3328   1792    123
27      6052    809    13%    5120   3200   1920    123
28      6052    809    13%    5120   3072   2048    123
28      6052    807    13%    5120   2944   2176    125
29      6052    807    13%    5120   2816   2304    125
29      6052    807    13%    5120   2688   2432    125
30      6052    807    13%    5120   2560   2560    125
30      6052    804    13%    5120   2432   2688    128
31      6052    804    13%    5120   2432   2688    128
31      6052    804    13%    5120   2176   2944    128
32      6052    804    13%    5120   2048   3072    128
32      6052    802    13%    5120   2048   3072    130
33      6052    674    11%    5376   2176   3200      2
33      8128   2638    32%    2304   2304      0   3186
34      8128   2508    30%    2432   2432      0   3188
34      8128   2380    29%    2560   2560      0   3188
35      8128   2252    27%    2688   2688      0   3188
35      8128   2124    26%    2816   2816      0   3188
36      8128   1994    24%    2944   2944      0   3190
36      8128   1740    21%    3200   3072    128   3188
37      8128   1740    21%    3328   3200    128   3060
37      8128   1612    19%    3328   3328      0   3188
38      8128   1484    18%    3584   3456    128   3060
38      8128   1353    16%    3584   3584      0   3191
39      8128   1225    15%    3840   3712    128   3063
39      8128   1101    13%    3840   3840      0   3187
40      8128    971    11%    3968   3968      0   3189
40      8128    843    10%    4096   4096      0   3189
41      8128    715     8%    4224   4224      0   3189
41      8128    587     7%    4352   4352      0   3189
42      8128   3412    41%    4608   4608      0    108
42      8128   3410    41%    4608   4608      0    110
43      8128   3280    40%    4736   4736      0    112
43      8128   3152    38%    4864   4864      0    112
44      8128   2896    35%    5120   4992    128    112
44      8128   2894    35%    5120   4992    128    114
45      8128   2894    35%    5120   4864    256    114
45      8128   2894    35%    5120   4736    384    114
46      8128   2894    35%    5120   4608    512    114
46      8128   2892    35%    5120   4480    640    116
47      8128   2892    35%    5120   4352    768    116
47      8128   2892    35%    5120   4224    896    116
48      8128   2892    35%    5120   4096   1024    116
48      8128   2890    35%    5120   3968   1152    118
49      8128   2890    35%    5120   3840   1280    118
49      8128   2890    35%    5120   3712   1408    118
50      8128   2890    35%    5120   3584   1536    118
50      8128   2888    35%    5120   3456   1664    120
51      8128   2888    35%    5120   3328   1792    120
51      8128   2888    35%    5120   3200   1920    120
52      8128   2888    35%    5120   3072   2048    120
52      8128   2886    35%    5120   2944   2176    122
53      8128   2886    35%    5120   2816   2304    122
53      8128   2886    35%    5120   2688   2432    122
54      8128   2886    35%    5120   2560   2560    122
54      8128   2884    35%    5120   2432   2688    124
55      8128   2884    35%    5120   2304   2816    124
55      8128   2884    35%    5120   2176   2944    124
56      8128   2884    35%    5120   2048   3072    124
56      8128   2882    35%    5120   2048   3072    126
57      8128   2754    33%    5376   2176   3200     -2
57      8128   2642    32%    5376   2304   3072    110
58      8128   2512    30%    5504   2432   3072    112
58      8128   2384    29%    5632   2560   3072    112
59      8128   2256    27%    5760   2688   3072    112
59      8128   2125    26%    5888   2816   3072    115
60      8128   1997    24%    6016   2944   3072    115
60      8128   1873    23%    6144   3072   3072    111
61      8128   1743    21%    6272   3200   3072    113
61      8128   1615    19%    6528   3328   3200    -15
62      8128   1487    18%    6528   3456   3072    113
62      8128   1357    16%    6656   3584   3072    115
63      8128   1229    15%    6784   3712   3072    115
63      8128   1105    13%    6912   3840   3072    111
64      8128    975    11%    7040   3968   3072    113
64      8128    847    10%    7168   4096   3072    113
65      8128    719     8%    7296   4224   3072    113
65      8128    589     7%    7424   4352   3072    115
66      8128    461     5%    7552   4480   3072    115
66      8128    336     4%    4608   4608      0   3184
67      8128    206     2%    4864   4736    128   3058
67      8128   3154    38%    4864   4864      0    110
68      8128   3024    37%    4992   4992      0    112
68      8128   2896    35%    5120   4992    128    112
69      8128   2896    35%    5120   4864    256    112
69      8128   2896    35%    5120   4736    384    112
70      8128   2894    35%    5120   4608    512    114
70      8128   2894    35%    5120   4480    640    114
71      8128   2894    35%    5120   4352    768    114
71      8128   2894    35%    5120   4224    896    114
72      8128   2891    35%    5120   4096   1024    117
72      8128   2891    35%    5120   3968   1152    117
73      8128   2891    35%    5120   3840   1280    117
73      8128   2891    35%    5120   3712   1408    117
74      8128   2889    35%    5120   3584   1536    119
74      8128   2889    35%    5120   3456   1664    119
75      8128   2889    35%    5120   3328   1792    119
75      8128   2889    35%    5120   3200   1920    119
76      8128   2887    35%    5120   3072   2048    121
76      8128   2887    35%    5120   3072   2048    121
77      8128   2887    35%    5120   2816   2304    121
77      8128   2887    35%    5120   2688   2432    121
78      8128   2885    35%    5120   2560   2560    123
78      8128   2885    35%    5120   2432   2688    123
79      8128   2885    35%    5120   2304   2816    123
79      8128   2885    35%    5120   2176   2944    123
80      8128   2883    35%    5120   2048   3072    125
80      8128   2883    35%    5120   2048   3072    125
81      8128   2755    33%    5248   2176   3072    125
81      8128   2627    32%    5376   2304   3072    125
82      8128   2497    30%    5504   2432   3072    127
82      8128   2385    29%    5632   2560   3072    111
83      8128   2255    27%    5760   2688   3072    113
83      8128   2127    26%    5888   2816   3072    113
84      8128   1999    24%    6016   2944   3072    113
84      8128   1869    22%    6272   3072   3200    -13
85      8128   1741    21%    6400   3200   3200    -13
85      8128   1487    18%    6528   3456   3072    113
86      8128   1359    16%    6656   3584   3072    113
86      8128   1231    15%    6784   3712   3072    113
87      8128   1103    13%    6912   3840   3072    113
87      8128    972    11%    7040   3968   3072    116
88      8128    851    10%    7168   4096   3072    109
88      8128    719     8%    7296   4224   3072    113
89      8128    591     7%    7424   4352   3072    113
89      8128    463     5%    7552   4480   3072    113
90      8128    335     4%    7680   4608   3072    113
90      8128    204     2%    7808   4736   3072    116
91      8128    209     2%    6784   4736   2048   1135
Exception in thread "main" java.lang.OutOfMemoryError: 
Java heap space
        at GCTest$MyObject.<init>(GCTest.java:54)
        at GCTest.myTest(GCTest.java:31)
        at GCTest.main(GCTest.java:21)

Output of other tests are similar to JDK 1.4.0.

Last update: 2007.

Table of Contents

 About This Book

 Download and Install Java SE 1.6 Update 2

 java.lang.Runtime Class - The JVM Instance

 java.lang.System Class - The Operating System

 ClassLoader Class - Class Loaders

 Class Class - Class Reflections

 Sun's JVM - Java HotSpot VM

 JRockit JVM 7.0 by BEA Systems

 JRockit JVM 8.0 by BEA Systems

 Memory Management Rules and Tests

Garbage Collection Tests

 GCTest.java - Garbage Collection Test Program

 GC Test - Constant Memory Requirement

 GC Test - Periodical Memory Requirement

 GC Test - Releasing Old vs. New Objects

 GC Test - JDK 1.4.0 vs. JDK 1.3.1

 GC Test - Client vs. Server

GC Test - JDK 1.6.0 vs. JDK 1.4.0

 Stack Overflow Tests

 Thread Testing Program and Result

 StringBuffer Testing Program and Result

 CDS (Class Data Sharing)

 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

 Micro Benchmark Tests on "float" and "double" Operations

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2010
GC Test - JDK 1.6.0 vs. JDK 1.4.0