我在哪里可以在 Windows pc 上永久设置 java 堆大小?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4308364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 15:43:07  来源:igfitidea点击:

Where can I permanently set java heap size on Windows pc?

javamemorytomcatjvmheap

提问by katura

I recently downloaded the latest Java 1.6 JDK. I'm using VisualVM which came with the SDK to test/monitor my webapp (using Tomcat server) on my local pc. I'm running Windows XP.

我最近下载了最新的 Java 1.6 JDK。我正在使用 SDK 附带的 VisualVM 来测试/监控我本地 PC 上的 web 应用程序(使用 Tomcat 服务器)。我正在运行 Windows XP。

Where are the parameters located for setting the min. and max. java heap size?VisualVM indicates that the max. heap is at about 256mb. I looked in the server.xml file for Tomcat, but didn't find any settings in there.

设置最小值的参数在哪里?和最大。java堆大小?VisualVM 表示最大。堆大约为 256mb。我查看了 Tomcat 的 server.xml 文件,但没有找到任何设置。

Thank you

谢谢

采纳答案by vijay.shad

You can use the JAVA_OPTS environment variable for dealing with java heap size. This variable can be added as a environment variable as well as you can define a configuration line in the startup.batfile.

您可以使用 JAVA_OPTS 环境变量来处理 Java 堆大小。可以将此变量添加为环境变量,也可以在startup.bat文件中定义配置行。

Add the following line in the startup.batfile.

startup.bat文件中添加以下行。

set JAVA_OPTS=-Xms512m -Xmx512m

You can add this as environment variable as said.

如上所述,您可以将其添加为环境变量。

回答by matt b

The best place to place these settings is in setenv.bator setenv.shin the binfolder. Take a look at a recent SO question on the same topic which has excellent answers.

放置这些设置的最佳位置是在setenv.batsetenv.sh将在bin文件夹中。看看最近关于同一主题的 SO 问题,它有很好的答案

回答by AlexR

These parameters are passed to JVM via command line: -Xms and -Xmx For more information run java -X.

这些参数通过命令行传递给 JVM: -Xms 和 -Xmx 有关更多信息,请运行 java -X。