programmatically setting max java heap size(以编程方式设置最大 Java 堆大小)
问题描述
有没有办法以编程方式设置最大 java 堆大小而不是作为 vm 参数?
Is there a way to set the max java heap size programmatically instead of as a vm argument?
类似:
System.getProperties().put("<heap variable>", "1000m");
推荐答案
不适用于任何 Hotspot JVM.JVM 堆参数只能在命令行中指定,然后在 JVM 的生命周期内固定.
Not with any Hotspot JVM. The JVM heap parameters can only be specified on the command line, and are then fixed for the lifetime of the JVM.
使用 Hotspot Java 实现,更改"应用程序的堆大小的唯一方法是在具有不同命令行参数的新 JVM 中重新启动它.
With Hotspot Java implementations, the only way to "change" the heap size of an application is to relaunch it in a new JVM with different command line parameters.
(我隐约记得其他一些供应商的 JVM确实允许在运行的 JVM 中更改一些堆参数.也许有人可以澄清一下.)
(I vaguely recall that JVMs from some other vendors do allow some heap parameters to be changed in a running JVM. Perhaps someone can clarify.)
这篇关于以编程方式设置最大 Java 堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:以编程方式设置最大 Java 堆大小


基础教程推荐
- 不推荐使用 Api 注释的描述 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
- 从 python 访问 JVM 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 大摇大摆的枚举 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01