1

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 :)

Endre Hovde
  • 624
  • 3
  • 7
  • 21
  • If you don't have [PAE](http://en.wikipedia.org/wiki/Physical_Address_Extension) enabled in your kernel, Ubuntu will never be able to support more than 4GB of RAM. Even if you do, the JVM might not be able to access it all; IIRC, a program has to be prepared for PAE to take full advantage of it, and if the JVM isn't, you have to account for the psace required for all of the other stuff that has to be in memory, like the JVM itself. It might very well be easier to just upgrade to 64-bit Ubuntu and JVM. – Michael Madsen May 25 '11 at 21:11
  • PAE only allows for the kernel to manage more. Each individual process still cannot break the limit. – Thorbjørn Ravn Andersen May 25 '11 at 21:14
  • Yeh, maybe I should go for x64, was to lazy to download a new copy. – Endre Hovde May 25 '11 at 21:16

2 Answers2

6

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.).

Community
  • 1
  • 1
Mat
  • 202,337
  • 40
  • 393
  • 406
  • Also there is a 64bit JVM, that allows you to have up to 2^64 bytes ) in it's memory. – dhblah May 25 '11 at 21:09
  • Is it hard to find x64 version of JRE for ubuntu? – Endre Hovde May 25 '11 at 21:14
  • @NoobiCake: I don't know, I don't use Ubuntu. There's askubuntu.com that's a stackechange site if you can't find it/install it. Note that you'll need a 64bit install of Ubuntu to get a 64bit JVM to run. – Mat May 25 '11 at 21:17
0

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.

Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347