0

This goes to all Java heap/GC experts out there. Simple and straight question: is there a hard limit on the maximum figure one can set the Java heap size to?

One of the servers I'm working on is hosting an in-memory real-time communication system, and the clients using the server have asked me to increase the amount of memory to 192Gb (it's not a typo: 192 GigaBytes!). Technically this is possible because the machine is virtual.

Besides the one above, my other questions are:

  • how well is the JVM going to handle such size?
  • is there any showstopper in setting it?
  • is there something I should be aware of, when dealing with such sizes?

Thanks in advance to anyone willing to help.

Regards.

Diferdin
  • 1,252
  • 1
  • 14
  • 30
  • if you have a test system and need a program to grab heap size I can help you. would be interested to know results. – tgkprog May 01 '13 at 16:17
  • Thanks. What do you mean exaclty with 'grab heap size'? – Diferdin May 01 '13 at 16:19
  • I'm not sure if I can help but, in any case, to allow others to contribute, which OS and which JVM are you using? – wmorrison365 May 01 '13 at 16:21
  • use it, so you know if there is a hard limit. first milestone would be to get the jvm to start. i would guess you need to play with other -X settings – tgkprog May 01 '13 at 16:22

2 Answers2

1

1) Have them consider the implications of having the virtual machine swapping stuff in and out of memory to disk with their code doing it. Sometimes its just as good and no extra work to let the VM do it. Sometimes it is much faster when they know something about the data characteristics and their optimizations are targeted that way.

2) Consider the possible use of multiple JVMs either cooperating or running in parallel with the scope of operation divided up somehow. Sometimes even running 4 JVMs running the same application on the same VM with each using 1/4 of the memory can be better. (Depends on your application's characteristics.)

3) Consider a memory management framework like TerraCotta's Big Memory. There are competitors in this space. For example, VMWare has Elastic Memory. They use memory outside the JVM's heap to store stuff and avoid the GC issue. Or they allocate very large heap objects and manage it independently of Java.

4) JVMs do ok(TM) if the memory gets taken up by live objects and they end up moving to the older generations for garbage collection. GC can be a problem. This is a black art. Be sure to kill a chicken and spread the feathers over the virtual machine before attempting to optimize GC. :) Oh ... and there are some really interesting comments here: Java very large heap sizes

5) Sometimes you set the JVM size and other factors beyond your control will keep it from growing that large. Be sure to do some testing to make sure it is really able to grow to the size you set.

And number 5 is the real key item. Test. Test. And test some more. You are out on the edges of explored territory.

Community
  • 1
  • 1
Lee Meador
  • 12,829
  • 2
  • 36
  • 42
1

The JVM spec for java 7 does not indicate that there is a hard limit.

I'd suggest that it is therefore goverened by your OS and the amount of memory available. However, you will have to be aware that the JVM needs enough memory for other internal structures (as the spec describes), such as PermGen, constant pool, etc. I'd also suggest that you consider profiling before arbitrarily increasing the heap size. It's possible that your old-gen space is hogging memory. I'd use VisualGC (now in VisualVM) to watch the memory usage and YourKit to look for leaks (its generational capabilities are a real help).

I've not answered your other questions but probably couldn't say more than your other respondents.

wmorrison365
  • 5,995
  • 2
  • 27
  • 40