t3chris
t3chris

Reputation: 1380

How do you deal with Java applications on the client requiring a lot of memory ("-J-Xmx"?

I have a Java SE desktop application which uses a lot of memory (1,1 GB would be desired). All target machines (Win 7, Win Vista) have plenty of physical memory (at least 4GB, most of them have more). There is also enough free memory.

Now, when the machines have some uptime and a lot of programs were started and terminated, the memory becomes fragmented (this is what I assume). This leads to the following error when the JVM is started:

  JVM creation failed
  Error occurred during initialization of VM
  Could not reserve enough space for object heap

Even closing all running programs doesn't help in such a situation (despite Task Manager and other tools report enough free memory). The only thing thas helps is to reboot the machine and fire up the Java applicaton as one of the first programs launched. As far as I've investigated, the Oracle VM requires one contiguous chunk of memory.

Is there any other way to assign about 1,1 GB of heap to my java application when this amount is available but may be fragmented?

I start my JVM with the following arguments:

-J-client -J-Xss2m -J-Xms512m -J-Xmx1100m -J-XX:PermSize=64m -J-Dsun.zip.disableMemoryMapping=true

Upvotes: 1

Views: 295

Answers (1)

Peter Lawrey
Peter Lawrey

Reputation: 533530

Is there any other way to assign about 1,1 GB of heap to my java application when this amount is available but may be fragmented?

Use an OS which doesn't get fragmented virtual memory. e.g. 64-bit windows or any version of UNIX.

BTW It is hard for me to imagine how this is possible in the first place but I know it to be the case. Each process has its own virtual memory so its arrangement of virtual memory shouldn't depend on anything which is already running or has run before.

I believe it might be a hang over from the MS-DOS TSR days. Shared libraries loaded are given absolute addresses (added to the end of the signed address space, 2 GB, the high half is reserved for the OS and the last 512 MB for the BIOS) in memory meaning they must use the same address range in every program they are used in. Over time the maximum address is determined by the lowest shared library loaded or used (I don't know which one by I suspect the lowest loaded)

Upvotes: 2

Related Questions