java 在 Linux 系统上增加堆大小

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38992738/
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-11-03 03:59:46  来源:igfitidea点击:

Increasing Heap size on Linux system

javalinux

提问by Indrakaran

I work on linux machine and I'd like to set min heap size and also want to increase the max heap size for Java. The RAM is 4GB and the current Max Heap Size is 1GB. Can you please guide me up to what value can I increase the max heap and also what min heap size I need to set for the above configuration.

我在 linux 机器上工作,我想设置最小堆大小,还想增加 Java 的最大堆大小。RAM 为 4GB,当前最大堆大小为 1GB。您能否指导我增加最大堆的值以及我需要为上述配置设置的最小堆大小。

回答by Rudzianko?

Java Heap SizePlace to store objects created by your Java application, this is where Garbage Collection takes place, the memory used by your Java application. For a heavy Java process, insufficient Heap size will cause the popular java.lang.OutOfMemoryError: Java heap space.

Java 堆大小用于存储 Java 应用程序创建的对象的位置,这是发生垃圾收集的地方,即 Java 应用程序使用的内存。对于繁重的Java进程,Heap size不足会导致流行的java.lang.OutOfMemoryError: Java heap space。

-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size

$ java -Xms512m -Xmx1024m JavaApp

Suggested Java MemoryBelow is suggested value for a small to medium Java application

建议的 Java 内存以下是中小型 Java 应用程序的建议值

Heap = -Xms512m -Xmx1024m

Source: https://www.mkyong.com/java/find-out-your-java-heap-memory-size/

来源:https: //www.mkyong.com/java/find-out-your-java-heap-memory-size/

回答by user2393256

This should help

这应该有帮助

-Xms<size>        set initial Java heap size
-Xmx<size>        set maximum Java heap size
-Xss<size>        set java thread stack size

java -Xms4g -Xmx4g ClassName