简体   繁体   English

为 memory 密集型应用程序增加 JVM 最大堆大小

[英]Increasing the JVM maximum heap size for memory intensive applications

I need to run a Java memory intensive application that uses more than 2GB, but I am having problems to increase the heap maximum size.我需要运行 Java memory 使用超过 2GB 的密集型应用程序,但我在增加堆最大大小时遇到问题。 So far, I have tried the following approaches:到目前为止,我已经尝试了以下方法:

  • Setting the -Xmx parameter, eg -Xmx3000m.设置-Xmx 参数,例如-Xmx3000m。 This approaches fails at the creation of the JVM. From what I've googled, it looks like that -Xmx must be less than 2GB.这种方法在创建 JVM 时失败了。从我用谷歌搜索的结果来看,-Xmx 似乎必须小于 2GB。

  • Using the -XX:+AggressiveHeap option .使用-XX:+AggressiveHeap 选项 When I try this approach I get an 'Not enough memory' error that tells that the heap size is 1273.4 MB, even though my computer has 8GB of memory.当我尝试这种方法时,我收到“内存不足”错误,提示堆大小为 1273.4 MB,即使我的计算机有 8GB 的 memory。

Is there another approach that I can try to increase the maximum heap size of the JVM?是否有另一种方法可以尝试增加 JVM 的最大堆大小? Here's a summary of the computer specs:以下是计算机规格的摘要:

  • OS: Windows 7 (64 bit)操作系统:Windows 7(64 位)
  • Processor: Intel Core i7 (2.66 GHz)处理器:英特尔酷睿 i7 (2.66 GHz)
  • Memory: 8 GB Memory:8GB
  • java -version: java-版本:
 java version "1.6.0_18" Java(TM) SE Runtime Environment (build 1.6.0_18-b07) Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)

When you are using JVM in 32-bit mode, the maximum heap size that can be allocated is 1280 MB.在 32 位模式下使用 JVM 时,可以分配的最大堆大小为 1280 MB。 So, if you want to go beyond that, you need to invoke JVM in 64-mode.所以,如果你想超越它,你需要在 64 模式下调用 JVM。

You can use following:您可以使用以下内容:

$ java -d64 -Xms512m -Xmx4g HelloWorld

where,在哪里,

  • -d64: Will enable 64-bit JVM -d64:将启用 64 位 JVM
  • -Xms512m: Will set initial heap size as 512 MB -Xms512m:将初始堆大小设置为 512 MB
  • -Xmx4g: Will set maximum heap size as 4 GB -Xmx4g:将最大堆大小设置为 4 GB

You can tune in -Xms and -Xmx as per you requirements (YMMV)您可以根据需要调整 -Xms 和 -Xmx (YMMV)

A very good resource on JVM performance tuning, which might want to look into: http://java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html关于 JVM 性能调整的非常好的资源,可能需要查看: http : //java.sun.com/javase/technologies/hotspot/gc/gc_tuning_6.html

Oracle获取 64 位 JVM。

I believe the 2GB limit is for 32-bit Java.我相信 2GB 的限制是针对 32 位 Java 的。 I thought v1.6 was always 64 bit, but try forcing 64 bit mode just to see: add the -d64 option.我认为 v1.6 总是 64 位,但尝试强制 64 位模式只是为了查看:添加 -d64 选项。

32-bit Java is limited to approximately 1.4 to 1.6 GB. 32 位 Java 被限制为大约 1.4 到 1.6 GB。

Oracle 32 bit heap FAQ Oracle 32 位堆常见问题解答

Quote引用

The maximum theoretical heap limit for the 32-bit JVM is 4G. 32 位 JVM 的最大理论堆限制为 4G。 Due to various additional constraints such as available swap, kernel address space usage, memory fragmentation, and VM overhead, in practice the limit can be much lower.由于可用交换、内核地址空间使用、内存碎片和 VM 开销等各种附加限制,实际上限制可能要低得多。 On most modern 32-bit Windows systems the maximum heap size will range from 1.4G to 1.6G.在大多数现代 32 位 Windows 系统上,最大堆大小范围为 1.4G 到 1.6G。 On 32-bit Solaris kernels the address space is limited to 2G.在 32 位 Solaris 内核上,地址空间限制为 2G。 On 64-bit operating systems running the 32-bit VM, the max heap size can be higher, approaching 4G on many Solaris systems.在运行 32 位 VM 的 64 位操作系统上,最大堆大小可以更高,在许多 Solaris 系统上接近 4G。

Below conf works for me:以下 conf 对我有用:

JAVA_HOME=/JDK1.7.51-64/jdk1.7.0_51/
PATH=/JDK1.7.51-64/jdk1.7.0_51/bin:$PATH
export PATH
export JAVA_HOME

JVM_ARGS="-d64 -Xms1024m -Xmx15360m -server"

/JDK1.7.51-64/jdk1.7.0_51/bin/java $JVM_ARGS -jar `dirname $0`/ApacheJMeter.jar "$@"

For memory intensive applications, GraalVm can serve as a better alternative.对于 memory 密集型应用程序,GraalVm 可以作为更好的替代方案。 Providing 32 GB as max heap size and other benefits.提供 32 GB 作为最大堆大小和其他好处。 Hotspot vs Graal 热点 vs Graal

In my case,就我而言,

-Xms1024M -Xmx1024M is work -Xms1024M -Xmx1024M 正常工作

-Xms1024M -Xmx2048M result: Could not reserve enough space for object heap -Xms1024M -Xmx2048M 结果:无法为对象堆保留足够的空间

after use JVM 64 bit, it allows using 2GB RAM, because I am using win server 2012使用 JVM 64 位后,它允许使用 2GB RAM,因为我使用的是 win server 2012

please see the available max heap size for JVM 32 bit on several OSs请查看多个操作系统上 JVM 32 位可用的最大堆大小用于 JVM 32 位的 Xmx

https://www.codementor.io/@suryab/does-32-bit-or-64-bit-jvm-matter-anymore-w0sa2rk6z https://www.codementor.io/@suryab/does-32-bit-or-64-bit-jvm-matter-anymore-w0sa2rk6z

i have "similar" memory issues to parse a 400mb json file via the JSONReader node. 我有“类似”的内存问题,通过JSONReader节点解析400mb json文件。

i have increased -Xmx12228m in the knime.ini but the heaps space seems to be capped at 5462mb 我在knime.ini中增加了-Xmx12228m,但堆积空间似乎上限为5462mb

在此输入图像描述

my laptop has 16gb of ram, so that should be sufficient, right? 我的笔记本电脑有16GB的内存,所以这应该足够了吧?

-->installation details: knime_3.6.2\\plugins/org.knime.binary.jre.win32.x86_64_1.8.0.152-01/jre/bin\\server\\jvm.dll - >安装细节:knime_3.6.2 \\ plugins / org.knime.binary.jre.win32.x86_64_1.8.0.152-01 / jre / bin \\ server \\ jvm.dll

Thx, 谢谢,

H H

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM