From 2cb40af048f2570f86f4a892717a3643acd25908 Mon Sep 17 00:00:00 2001 From: spearhead0428 Date: Mon, 29 May 2023 00:38:08 +0800 Subject: [PATCH] 23232 --- src/main/java/com/github/hcsp/objectbasic/Main.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/github/hcsp/objectbasic/Main.java b/src/main/java/com/github/hcsp/objectbasic/Main.java index 3ac28ea..44323b7 100644 --- a/src/main/java/com/github/hcsp/objectbasic/Main.java +++ b/src/main/java/com/github/hcsp/objectbasic/Main.java @@ -1,7 +1,16 @@ package com.github.hcsp.objectbasic; +import java.util.ArrayList; +import java.util.List; + public class Main { public static void main(String[] args) { - // 请想办法在这里写一些代码,占用尽可能多的内存,令JVM抛出内存不足的OutOfMemoryError异常 + List list = new ArrayList<>(); + while (true) + { + byte[] array = new byte[Integer.MAX_VALUE]; + list.add(array); + } } + // 请想办法在这里写一些代码,占用尽可能多的内存,令JVM抛出内存不足的OutOfMemoryError异常 }