import java.util.ArrayList;
import java.util.List;
public class MemoryLeak {
private static List<byte[]> list = new ArrayList<>();
public static void main(String[] args) {
while (true) {
list.add(new byte[1024*1024]);
}
}
}
java -cp . -XX:+UseSerialGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log MemoryLeak
java -cp . -XX:+UseParallelGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log MemoryLeak

OpenJDK 64-Bit Server VM (25.432-b06) for linux-amd64 JRE (1.8.0_432-b06), built on Oct 16 2024 00:00:00 by "mockbuild" with gcc 11.4.1 20231218 (Red Hat 11.4.1-3)
Memory: 4k page, physical 414772k(155524k free), swap 4141052k(4067876k free)
CommandLine flags: -XX:InitialHeapSize=6815736 -XX:MaxHeapSize=130862280 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseSerialGC
2024-12-06T11:25:21.955+0900: 0.049: [GC (Allocation Failure) 2024-12-06T11:25:21.955+0900: 0.049: [DefNew: 1433K->255K(2432K), 0.0006748 secs] 1433K->1286K(7936K), 0.0007227 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2024-12-06T11:25:21.956+0900: 0.050: [GC (Allocation Failure) 2024-12-06T11:25:21.956+0900: 0.050: [DefNew: 2346K->0K(2432K), 0.0005067 secs] 3377K->3334K(7936K), 0.0005449 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2024-12-06T11:25:21.956+0900: 0.051: [GC (Allocation Failure) 2024-12-06T11:25:21.956+0900: 0.051: [DefNew: 2085K->0K(2560K), 0.0005079 secs] 5419K->5382K(8064K), 0.0005217 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2024-12-06T11:25:21.957+0900: 0.051: [GC (Allocation Failure) 2024-12-06T11:25:21.957+0900: 0.051: [DefNew: 2088K->0K(2560K), 0.0006380 secs]2024-12-06T11:25:21.958+0900: 0.052: [Tenured: 7430K->7430K(7560K), 0.0008127 secs] 7470K->7430K(10120K), [Metaspace: 2948K->2948K(1056768K)], 0.0014921 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
2024-12-06T11:25:21.960+0900: 0.054: [GC (Allocation Failure) 2024-12-06T11:25:21.960+0900: 0.054: [DefNew: 4188K->0K(5632K), 0.0009808 secs] 11618K->11526K(18016K), 0.0010038 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2024-12-06T11:25:21.961+0900: 0.055: [GC (Allocation Failure) 2024-12-06T11:25:21.961+0900: 0.055: [DefNew: 4190K->0K(5632K), 0.0010691 secs]2024-12-06T11:25:21.962+0900: 0.056: [Tenured: 15622K->15622K(16496K), 0.0013988 secs] 15717K->15622K(22128K), [Metaspace: 2948K->2948K(1056768K)], 0.0025409 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2024-12-06T11:25:21.964+0900: 0.059: [GC (Allocation Failure) 2024-12-06T11:25:21.965+0900: 0.059: [DefNew: 10439K->1024K(11776K), 0.0019322 secs] 26062K->25862K(37816K), 0.0019884 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2024-12-06T11:25:21.967+0900: 0.061: [GC (Allocation Failure) 2024-12-06T11:25:21.967+0900: 0.061: [DefNew: 11467K->1024K(11776K), 0.0033877 secs]2024-12-06T11:25:21.970+0900: 0.065: [Tenured: 35078K->35079K(35292K), 0.0010737 secs] 36306K->36103K(47068K), [Metaspace: 2948K->2948K(1056768K)], 0.0045583 secs] [Times: user=0.00 sys=0.01, real=0.01 secs]
2024-12-06T11:25:21.974+0900: 0.069: [GC (Allocation Failure) 2024-12-06T11:25:21.974+0900: 0.069: [DefNew: 22968K->2048K(26368K), 0.0090369 secs] 58047K->57607K(84836K), 0.0091114 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
2024-12-06T11:25:21.985+0900: 0.079: [GC (Allocation Failure) 2024-12-06T11:25:21.985+0900: 0.079: [DefNew: 25016K->2048K(26368K), 0.0103041 secs]2024-12-06T11:25:21.995+0900: 0.089: [Tenured: 78087K->78086K(79028K), 0.0073741 secs] 80576K->80134K(105396K), [Metaspace: 2948K->2948K(1056768K)], 0.0178791 secs] [Times: user=0.01 sys=0.01, real=0.02 secs]
2024-12-06T11:25:22.006+0900: 0.100: [GC (Allocation Failure) 2024-12-06T11:25:22.006+0900: 0.100: [DefNew: 33424K->33424K(38720K), 0.0000121 secs]2024-12-06T11:25:22.006+0900: 0.100: [Tenured: 78086K->85254K(86016K), 0.0058959 secs] 111510K->110854K(124736K), [Metaspace: 2948K->2948K(1056768K)], 0.0059967 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
2024-12-06T11:25:21.985+0900: 0.079: [GC (Allocation Failure) 2024-12-06T11:25:21.985+0900: 0.079: [DefNew: 25016K->2048K(26368K), 0.0103041 secs]2024-12-06T11:25:21.995+0900: 0.089: [Tenured: 78087K->78086K(79028K), 0.0073741 secs] 80576K->80134K(105396K), [Metaspace: 2948K->2948K(1056768K)], 0.0178791 secs] [Times: user=0.01 sys=0.01, real=0.02 secs]
2024-12-06T11:25:22.006+0900: 0.100: [GC (Allocation Failure) 2024-12-06T11:25:22.006+0900: 0.100: [DefNew: 33424K->33424K(38720K), 0.0000121 secs]2024-12-06T11:25:22.006+0900: 0.100: [Tenured: 78086K->85254K(86016K), 0.0058959 secs] 111510K->110854K(124736K), [Metaspace: 2948K->2948K(1056768K)], 0.0059967 secs] [Times: user=0.00 sys=0.00, real=0.01 secs]
2024-12-06T11:25:22.014+0900: 0.108: [Full GC (Allocation Failure) 2024-12-06T11:25:22.014+0900: 0.108: [Tenured: 85254K->85254K(86016K), 0.0019950 secs] 122766K->122119K(124736K), [Metaspace: 2948K->2948K(1056768K)], 0.0020563 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2024-12-06T11:25:22.016+0900: 0.111: [Full GC (Allocation Failure) 2024-12-06T11:25:22.016+0900: 0.111: [Tenured: 85254K->85254K(86016K), 0.0010269 secs] 123143K->123143K(124736K), [Metaspace: 2948K->2948K(1056768K)], 0.0010533 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
2024-12-06T11:25:22.018+0900: 0.113: [Full GC (Allocation Failure) 2024-12-06T11:25:22.018+0900: 0.113: [Tenured: 85254K->85242K(86016K), 0.0079074 secs] 123143K->123131K(124736K), [Metaspace: 2948K->2948K(1056768K)], 0.0079731 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
Heap
def new generation total 38720K, used 38528K [0x00000000f8200000, 0x00000000fac00000, 0x00000000fac00000)
eden space 34432K, 100% used [0x00000000f8200000, 0x00000000fa3a0000, 0x00000000fa3a0000)
from space 4288K, 95% used [0x00000000fa3a0000, 0x00000000fa7a0040, 0x00000000fa7d0000)
to space 4288K, 0% used [0x00000000fa7d0000, 0x00000000fa7d0000, 0x00000000fac00000)
tenured generation total 86016K, used 85242K [0x00000000fac00000, 0x0000000100000000, 0x0000000100000000)
the space 86016K, 99% used [0x00000000fac00000, 0x00000000fff3e990, 0x00000000fff3ea00, 0x0000000100000000)
Metaspace used 2985K, capacity 4486K, committed 4864K, reserved 1056768K
class space used 282K, capacity 386K, committed 512K, reserved 1048576K

OpenJDK 64-Bit Server VM (25.432-b06) for linux-amd64 JRE (1.8.0_432-b06), built on Oct 16 2024 00:00:00 by "mockbuild" with gcc 11.4.1 20231218 (Red Hat 11.4.1-3)
Memory: 4k page, physical 414772k(175572k free), swap 4141052k(4066376k free)
CommandLine flags: -XX:InitialHeapSize=6815736 -XX:MaxHeapSize=130862280 -XX:+PrintGC -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseParallelGC
2024-12-06T11:11:39.631+0900: 0.125: [GC (Allocation Failure) --[PSYoungGen: 1439K->1439K(2048K)] 86433K->86441K(88064K), 0.0012749 secs] [Times: user=0.00 sys=0.01, real=0.00 secs]
2024-12-06T11:11:39.632+0900: 0.127: [Full GC (Ergonomics) [PSYoungGen: 1439K->1285K(2048K)] [ParOldGen: 85001K->84993K(86016K)] 86441K->86278K(88064K), [Metaspace: 2947K->2947K(1056768K)], 0.0043021 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
2024-12-06T11:11:39.636+0900: 0.131: [GC (Allocation Failure) --[PSYoungGen: 1285K->1285K(2048K)] 86278K->86278K(88064K), 0.0006952 secs] [Times: user=0.01 sys=0.00, real=0.00 secs]
2024-12-06T11:11:39.637+0900: 0.132: [Full GC (Allocation Failure) [PSYoungGen: 1285K->1273K(2048K)] [ParOldGen: 84993K->84993K(86016K)] 86278K->86267K(88064K), [Metaspace: 2947K->2947K(1056768K)], 0.0032240 secs] [Times: user=0.01 sys=0.00, real=0.01 secs]
Heap
PSYoungGen total 2048K, used 1335K [0x00000000fd600000, 0x00000000fd880000, 0x0000000100000000)
eden space 1536K, 86% used [0x00000000fd600000,0x00000000fd74df38,0x00000000fd780000)
from space 512K, 0% used [0x00000000fd800000,0x00000000fd800000,0x00000000fd880000)
to space 512K, 0% used [0x00000000fd780000,0x00000000fd780000,0x00000000fd800000)
ParOldGen total 86016K, used 84993K [0x00000000f8200000, 0x00000000fd600000, 0x00000000fd600000)
object space 86016K, 98% used [0x00000000f8200000,0x00000000fd5005b8,0x00000000fd600000)
Metaspace used 2984K, capacity 4486K, committed 4864K, reserved 1056768K
class space used 282K, capacity 386K, committed 512K, reserved 1048576K