"Could not create the Java Virtual Machine" when increasing the -Xmx - java

The eclipse on my work computer was working with VM argument -Xms40m and -Xmx512m and it is really slow and freezes a lot, I wanted to increase it to -Xmx1024m, but every time I did so I got the error "Could not create the Java Virtual Machine".
The computer has 3.5GB RAM, WIN XP (32-bit), Java 1.6_18
What could be the reason? Is it related to other arguments?
UPDATE:
I changed the -vm argument so it will use the jvm.dll that comes with the jrockit JDK and I was able to increase the max heap size to 1024m.
Also, on my home computer (WIN 7, 32-bit, 2GB RAM, java 1.7.0_21-b11), I was able to increase it 1024m as well.

The maximum amount of memory available on Windows 32-bit processes is (generally speaking) 2GB. That includes everything for your JVM, not only the application heap. People report various numbers for the maximum heap that can use for a 32-bit JVM, but 1200m is a common figure. It seems to be lower for you. Best would be to switch to the 64-bit JVM, if you can.
Other questions:
How much memory can a 32 bit process access on a 64 bit operating system?
Java maximum memory on Windows XP

Related

setting up 64bit windows 7 for large JRE7 heap size

I have been trying to run java with 4G max and min heap size on a 64bit win 7 machine but when I check task manager I only see about 2G for java.exe. I read there are windows restrictions as well. How do I set up windows 7 and jre7 x64 so that I can run jave with 4G heap size?
Thanks.
What parameters are you using?
http://docs.oracle.com/javase/7/docs/technotes/tools/windows/java.html
For example related to your case:
-Xms : sets initial Java heap size
-Xmx : sets maximum Java heap size
If you are using the -Xmx parameter then you will see 4G in your task manager, ONLY IF your application really needs it. On the other hand if your are using the -Xms parameter (in that case you also need to need to set -Xmx parameter at an equal or larger value) then you should expect to see that value on the task manager. So, only if you set -Xms4096M and -Xmx4096M and the JVM fails to start then you have an issue. If it starts normally then you do not have a problem.
Also regardless of the RAM you are having (not in your case since we are only talking 4G) even Windows 7 (64bit) have different limits according to their edition.
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366778%28v=vs.85%29.aspx#physical_memory_limits_windows_7
Couple of times in my past experience, I observed that 64-bit OS can also have 32-bit JVM and it leads to the confusion.
Apart from this, I don't think you will be able to allocate full 4 GB space to JVM, there are other programs which consumes the memory also.
You can think of allocating 4 GB only if you are running on >6 GB machine.

Cant give JVM 3072m heap space on 32bit machine

Sorry for asking the question, should have searched a bit more.
Im running weka with a rather large dataset and a memory intesive algoithm. I need all the heap space I cant get!
This works:
java -jar -Xmx2048m weka.jar &
But this does not
java -jar -Xmx4096m weka.jar &
I get:
Error occurred during initialization of VM Could not reserve enough
space for object heap Could not create the Java virtual machine.
By some quick searching I found that this is the upper limit
java -jar -Xmx2594m weka.jar &
I have 4GB ram but a 32 bit machine. Why can't I use 2^32 bytes = 4096MB of memory?
For the future I am wondering if I can run java with e.g. hundreds of GB of heap space if I have the correct hardware and OS?
I have both 1.6 and 1.7 JVM installed:
$java -showversion
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.4) (6b24-1.11.4-1ubuntu0.12.04.1)
OpenJDK Server VM (build 20.0-b12, mixed mode)
I have 4GB ram but a 32 bit machine. Why can't I use 2^32 bytes = 4096MB of memory?
For the future I am wondering if I can run java with e.g. hundreds of GB of heap space if I have the correct hardware and OS?
For 4 GB I suggest you use a 64-bit OS and possibly a 64-bit JVM as the limit for the heap size can be as small as 1.2 GB (on Windows XP)
If you want larger JVMs I suggest making sure you have 64-bit OS and JVM and you have more memory than the size of the JVM. e.g. if you want a 40 GB heap you need something like 48 GB or 64 GB of memory.
Use the 64-bit version of Java which allows you to use more memory. This is the limit of the 32-bit Java virtual machine.
If you have 4GB of RAM how can you expect that all will be available to your JVM? What about the OS the JVM is running in, this will also require memory. The way it works is that even though you can address all 4GB generally an OS will limit the amount available per process.
You are not able to have an allocation of 4096m because. It tries to get a single block of 4096m. Which is not possible at any given point of time. So you can use some smaller values between
3000-4000. or make sure your RAM is not used by any of the processes

more memory allocation in java program

I use ubuntu 10.04 LTS 64bit and my system has 4 GB RAM.
I run a java program that need more than 1.1GB memory but the operating system does not allow my program to get more than 1.1GB while only 2.1GB of RAM is used and 1.9GB are free, what is the problem? (This problem is not just for this program, I run another program and has same problem.)
what should I do?
Looks like you are running a java application. Make sure to
Run a 64 bit JVM, if you need more than about 4GB memory. For this to work, you shold have a 64 bit OS
Increase the max heap size by the JVM switch
-Xms <initial size> -Xmx <max size>
Sounds like you programs are compiled as 32bit programs despite that you are running on a 64bit configuration.

How to get max Java VM higher than 2GB on ubuntu?

My virtual memory won't go higher than 2GB when I has 8GB available.
I'm running Ubuntu 10.10 x86 with Java JRE 1.6_25 installed.
When I try to launch the .jar file, it just an instantly crash.
It works just fine when I set the VM to 2048M
These are the arguments I use to define the VM -Xmx4096M -Xms4096M
Thankful for any help :)
If that's a 32bit VM, you won't go higher than 2G (or close to 3G with a kernel configured for 3G/1G userspace/kernel address space split). There is no way to have a 32bit process use more than 2G (or 3G with the right settings) of real memory.
You'll need a 64bit kernel and JVM to reach 4G of heap space (and go much beyond that).
See this question for good info about memory limits on Linux for 32bit applications: Memory limit to a 32-bit process running on a 64-bit Linux OS.
(The accepted answer talks both about 32bit and 64bit kernels. It also suggests that there were some patches where you could nearly reach 4G for userspace on a 32bit kernel, but I don't think those kind of things ever went into Ubuntu kernels - kind of a nich server thing.).
You should strongly consider migrating to a 64 bit operating system if you need that large a Java program. This will allow you to use a 64-bit JVM which allows for larger-than-2Gb Java programs.
I am not aware of a procedure to easily migrate from 32-bit to a 64-bit Ubuntu, but you can save your home directory and then reinstall.
You can then easily install the OpenJDK Java and with a bit more effort the official Sun JDK.

JVM Heapsize on 32 bit OS

I am using 32 bit win.7 and using Eclipse. Also having 4GB RAM.
I want to allocate my java application a maximum heapsize of around 3 GB, but I am able to allocate maximum 1.5GB through VM arguments -Xmx1056m.
What should I do? If I Install a 64 bit win.7. it would be able then to allocate 3GB heapsize to my app?
A regular 32-bit Windows process can only address 2GB of memory, even if you have more memory available. You can find the memory limits for different Windows versions here.
Since the VM need memory for more things than just the heap, the max heap size will be slightly less than the maxmimum memory available to the process. Usually, you can tweak the heap up to around 1.6GB for a 32-bit Windows VM.
You need a 64bit OS and 64bit VM to allocate this much RAM.
I don't have the link right now that describes the JVM memory management process. The limitation you have stumbled upon is a limitation of how Java performs garbage collection. The Java memory heap must be a contigious block. The garbage collection algorithms were optimized for this design limitation so they can perform efficiently. In a 32bit operating system, you are not in control of what memory addresses device drivers are loaded into. On Windows, the OS will only reallocate the device driver base address stored in the DLL if it conflicts with an already loaded code. Other operating systems may reallocate all device drivers on load so they live in a contiguous block near the kernel.
Basically, the limitation is the same for 64bit and 32bit operating systems. It's just on a 64bit OS there are several more address ranges to choose from. Make sure you use a 64bit JVM to match the OS. That's why the 64bit OS is able to find a larger contigious block of memory addresses than the 32bit OS.
EDIT: Additionally the 32bit JVM has a max heap size limit of 2GB.
REFERENCE:
http://publib.boulder.ibm.com/infocenter/javasdk/tools/index.jsp?topic=/com.ibm.java.doc.igaa/_1vg00014884d287-11c3fb28dae-7ff6_1001.html
Java maximum memory on Windows XP
http://forums.sun.com/thread.jspa?messageID=2715152#2715152
What you will need is not only a 64bit OS and a 64bit VM, but also more memory.
On a 32bits Windows system the virtual address space is split with 2 GB for kernel operations and 2 GB for user applications. So you're screwed.
There's one possible but very unlikely workaround: you can enable the /3GB switch to raise this limitation and have the system allocate 1GB of virtual address space for for kernel operations and 3GB for user applications (if they are /LARGEADDRESSPACEAWARE).
Unfortunately, the 32bits Sun/Oracle HotSpot JVM isn't LARGEADDRESSAWARE (that I know of), and other 32bits JVM likely aren't either.
But think about it: even if you were able to do that, you would use all the memory available for you system. Nothing would be left for other programs after you've allocated your 3GB of heap for your JVM. Your system would be swapping to disk all the time. It would be unusable.
Just get a 64bis OS with more RAM. That's all there is for you, short of finding ways to have your program use less memory.

Categories

Resources