How do you crash a JVM?(如何使 JVM 崩溃?)
问题描述
我正在阅读一本关于编程技巧的书,其中作者问受访者,你如何使 JVM 崩溃?"我认为你可以通过编写一个最终会耗尽所有内存的无限 for 循环来做到这一点.
I was reading a book on programming skills wherein the author asks the interviewee, "How do you crash a JVM?" I thought that you could do so by writing an infinite for-loop that would eventually use up all the memory.
有人知道吗?
推荐答案
最接近单一答案"的是 System.exit()
,它会立即终止 JVM,而无需进行适当的清理.但除此之外,本机代码和资源耗尽是最有可能的答案.或者,您可以在 Sun 的错误跟踪器上查找您的 JVM 版本中的错误,其中一些允许可重复的崩溃场景.在 32 位版本(我们现在通常使用 64 位)下接近 4 Gb 内存限制时,我们过去常常会出现半定期崩溃.
The closest thing to a single "answer" is System.exit()
which terminates the JVM immediately without proper cleanup. But apart from that, native code and resource exhaustion are the most likely answers. Alternatively you can go looking on Sun's bug tracker for bugs in your version of the JVM, some of which allow for repeatable crash scenarios. We used to get semi-regular crashes when approaching the 4 Gb memory limit under the 32-bit versions (we generally use 64-bit now).
这篇关于如何使 JVM 崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使 JVM 崩溃?


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01