问题
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. So far, I have tried the following approaches:
Setting the -Xmx parameter, e.g. -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.
Using the -XX:+AggressiveHeap option. 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.
Is there another approach that I can try to increase the maximum heap size of the JVM? Here\'s a summary of the computer specs:
- OS: Windows 7 (64 bit)
- Processor: Intel Core i7 (2.66 GHz)
- Memory: 8 GB
- java -version:
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)
回答1:
Get yourself a 64-bit JVM from Oracle.
回答2:
When you are using JVM in 32-bit mode, the maximum heap size that can be allocated is 1280 MB. So, if you want to go beyond that, you need to invoke JVM in 64-mode.
You can use following:
$ java -d64 -Xms512m -Xmx4g HelloWorld
where,
- -d64: Will enable 64-bit JVM
- -Xms512m: Will set initial heap size as 512 MB
- -Xmx4g: Will set maximum heap size as 4 GB
You can tune in -Xms and -Xmx as per you requirements (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
回答3:
I believe the 2GB limit is for 32-bit Java. I thought v1.6 was always 64 bit, but try forcing 64 bit mode just to see: add the -d64 option.
回答4:
32-bit Java is limited to approximately 1.4 to 1.6 GB.
Oracle 32 bit heap FAQ
Quote
The maximum theoretical heap limit for the 32-bit JVM is 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. On most modern 32-bit Windows systems the maximum heap size will range from 1.4G to 1.6G. On 32-bit Solaris kernels the address space is limited to 2G. On 64-bit operating systems running the 32-bit VM, the max heap size can be higher, approaching 4G on many Solaris systems.
回答5:
Below conf works for me:
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 "$@"
回答6:
i have "similar" memory issues to parse a 400mb json file via the JSONReader node.
i have increased -Xmx12228m in the knime.ini but the heaps space seems to be capped at 5462mb
my laptop has 16gb of ram, so that should be sufficient, right?
-->installation details: knime_3.6.2\plugins/org.knime.binary.jre.win32.x86_64_1.8.0.152-01/jre/bin\server\jvm.dll
Thx,
H
来源:https://stackoverflow.com/questions/3030263/increasing-the-jvm-maximum-heap-size-for-memory-intensive-applications