Hello, I'm trying to allow a java .jar file to use the 2gb's of memory available on my linux computer. However, I get an allocation error when using over 1024mb's on Xmx or Xms. How do I allow the system to give java the memory it needs.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hello, I'm trying to allow a java .jar file to use the 2gb's of memory available on my linux computer. However, I get an allocation error when using over 1024mb's on Xmx or Xms. How do I allow the system to give java the memory it needs.
Always copy-paste error messages. Perhaps you don't have as much memory spare as you're trying to give to Java? Are you running more than one instance of your program?an allocation error
I can't paste the message as it just shuts down after loading everything. But the message is, from what I can see. "Error can't allocate memory to java".
My system has 2.5gb's of memory, but when I set -Xmx -Xms higher then 1024mb's it gives me this error. I googled this and a few people said the system was blocking it from be able to allow more then 1024mb's.
If your system can't allocate memory, it doesn't have it to spare. What command line are you using? For example this doesn't work on my PC:
but it will run like thisjava -Xms22G -version Error occurred during initialization of VM Could not reserve enough space for object heap
It's not always obvious how much of your PC's memory is 'spare' - try to find out what value for Xms (on your system, something like Xms800M might be a good one to try) the problem starts at, let us have the output from -version, and some clue from your OS how much memory you have and how much is spare. I use 'top' to get summary memory stats on Ubuntu.java -Xms20G -version java version "1.6.0_24" OpenJDK Runtime Environment (IcedTea6 1.11.1) (6b24-1.11.1-4ubuntu2) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
Running "top" on my linux I see that I have:
Mem: 2621440k total, 1698936k used, 922504k free,
When Java is running with it's 1024M limit. Any number higher just gives me allocation errors.
and the output of "java -version"? Are you sure you're stopping the previous one before running the next one? You should have nearly 2G free before starting java
I checked the running processes and nothing for Java was running, still when I start it I get the error Can't Allocate Memory for any value higher then 1024MB.
what is the output of "java -version"?
You can post the output of uname -a too, if you like. And confirm for us that this is a physical machine and not a virtual one.
You're running a 32 bit JVM and/or you're environment limits you. A "ulimit -v" shows how much virtual memory (from an O/S level) your process is allowed to use. And I've never heard of a machine with 2.5 gig of memory but I guess it is possible.
A 32 bit JVM will likely top out at around 1.5 gig with a freshly rebooted system. A system that has been running a while might be less.
As Sean4u asked, we need a "java -version", a "uname -a" and I'd like the "ulimit -v". I'm a bit concerned that you can't grab an error message because it implies that you're not comfortable using a command line.
Need Java help? Check out the HotJoe Java Help forums!
Let me clear a few things up here, as I feel I've been a little misleading. First, my linux system is a virtual private server. Second, I'm running 32bit Ubuntu. Third, here is the information you wanted.
java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.6) (6b22-1.10.6-0ubuntu1)
OpenJDK Server VM (build 20.0-b11, mixed mode)
Linux server1 2.6.18-274.el5.028stab093.2 #1 SMP Tue Aug 23 16:46:17 MSD 2011 i686 athlon i386 GNU/Linux
unlimited
I hope this helps, and yes I have contacted my server provider about this and they are taking all month to get back to me. I thought it might be something Java could fix.
I'm personally not a big fan of OpenJDK though, I'll be honest, it's more because of my (depressingly long) history with the Sun/Oracle JDK than any true issues. 1.0 beta - that was my first experience...
Anyhow, you're a bit stuck with the environment you have. But I suppose the real question we all should have been asking is why does your app need 2GB of memory? There are plenty of valid reasons for using that much memory but there are likely more invalid reasons. What data/code/etc. is it caching that requires that kind of memory? I run production Glassfish servers supporting hundreds of simultaneous users on an Amazon instance. I allocate a total of 2GB for that and have never come close to running out of memory.
Can you describe your application a bit? Perhaps there are other paths.
Need Java help? Check out the HotJoe Java Help forums!
My application is a game server, to be specific a minecraft server. It needs this memory because everything runs off memory when you open it, if you have around 30 people playing at one time you can run out of memory very fast.
Ok, makes sense - look to upgrade your server a bit. I'm not familiar with OpenJDK limitations but even the real JDK will not get you too far past the 1GB mark.
Need Java help? Check out the HotJoe Java Help forums!
Reinstalling the operating system to Debian 6 64bit and "sun-java6-jdk" fixed the memory problem. Guess it was the 32bit operating system.
you was try linux red hat?