OutOfMemoryError
以下的这段代码应该是报错的才对,但是我在运行了之后,程序一直卡在那里。最后请教老师了解到,原来jvm如果不指定运行参数,是会进行自动扩容的。
package com.coding.jvm.oom;
public class NativeErrorDemo {
public static void main(String[] args) {
for (; ; ) {
new Thread(() -> {
try {
Thread.sleep(Integer.MAX_VALUE);
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
}
}
于是,在运行这段代码之前,我手动指定了以下内存大小。
最后,运行之,达到了自己想要模拟的结果:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
2021-05-18 The web application [ROOT] appears to have started a thread named [logback-1] but has failed to stop
2020-05-18 '�й� You must configure either the server or JDBC driver (via the 'serverTimezone' configuration property) to use a more specifc time zone value if you want to utilize time zone support. -> [Help 1]
2020-05-18 You must configure either the server or JDBC driver (via the serverTimezone conf)