在Windows中设置默认堆大小 [英] Set default heap size in Windows
问题描述
我想永久设置Java堆大小,并且不希望使用选项运行每个jar文件。
我使用Windows和Java 1.7。
I want to set Java heap size permanently and don't want to run every jar file with options. I use Windows and Java 1.7.
推荐答案
将 JAVA_OPTS 设置为系统变量以下内容:
Setup JAVA_OPTS as a system variable with the following content:
JAVA_OPTS = - Xms256m -Xmx512m
之后在命令提示符下运行以下命令:
After that in a command prompt run the following commands:
SET JAVA_OPTS="-Xms256m -Xmx512m"
这可以解释如下:
- 分配至少256MB的堆
- 分配最多512MB的堆
这些值应根据应用要求进行更改。
These values should be changed according to application requirements.
编辑:
您也可以尝试添加它通过环境属性菜单,可在以下位置找到:
You can also try adding it through the Environment Properties menu which can be found at:
- 从桌面,右键单击我的电脑,然后点击属性。
- 点击左栏中的高级系统设置链接。
- 在系统属性窗口中,单击环境变量按钮。
- 单击新建到添加新变量名称和值。
- 对于变量名称,输入 JAVA_OPTS 作为变量值输入 -Xms256m -Xmx512m
- 单击确定并关闭系统属性选项卡。
- 重新启动任何Java应用程序。
- From the Desktop, right-click My Computer and click Properties.
- Click Advanced System Settings link in the left column.
- In the System Properties window click the Environment Variables button.
- Click New to add a new variable name and value.
- For variable name enter JAVA_OPTS for variable value enter -Xms256m -Xmx512m
- Click ok and close the System Properties Tab.
- Restart any java applications.
编辑2:
JAVA_OPTS 是一个系统变量,可存储各种设置/配置本地 Java虚拟机。通过将 JAVA_OPTS 设置为系统变量,在 JVM 之上运行的所有应用程序都将从此参数中获取其设置。
JAVA_OPTS is a system variable that stores various settings/configurations for your local Java Virtual Machine. By having JAVA_OPTS set as a system variable all applications running on top of the JVM will take their settings from this parameter.
要设置系统变量,您必须完成上面列出的步骤1到4。
To setup a system variable you have to complete the steps listed above from 1 to 4.
这篇关于在Windows中设置默认堆大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!