Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Practical limitations of JVM memory and CPU usage?

Let's say money was not a limiting factor, and I wanted to write a Java program that ran on a single powerful machine.

The goal would be to make the Java program run as fast as possible without having to swap or go to disk for anything.

Let's say that this computer has:

  • 1 TB of RAM (64 16GB DIMMs)
  • 64 processor cores (8 8-core processors)
  • running 64-bit Ubuntu

Could a single instance of a java program running in a JVM take advantage of this much RAM and processors?

Are there any practical considerations that might limit the usage and efficiency?

  • OS process (memory & threads) limitations?
  • JVM memory/heap limitations?
  • JVM thread limitations?

Thanks, Galen

like image 386
Galen Avatar asked Jul 12 '11 16:07

Galen


People also ask

Why JVM heap utilization is too high?

This is because the JVM steadily increases heap usage percentage until the garbage collection process frees up memory again. High heap usage occurs when the garbage collection process cannot keep up. An indicator of high heap usage is when the garbage collection is incapable of reducing the heap usage to around 30%.

What is JVM CPU usage?

A JVM may max out on CPU usage because of the incoming workload. The server capacity may not be sized sufficiently to handle the rate of requests coming in and in such a situation, the Java application may be doing work, trying to keep up with the workload.

How much memory can JVM use?

Sizing the JVM By default, the HotSpot JVM will use up to 240MB. If the code cache is too small the JIT will run out of space to store its output and performance will suffer as a result. If the cache is too large, memory may be wasted.

What happens when JVM runs out of memory?

OutOfMemoryError is a runtime error in Java which occurs when the Java Virtual Machine (JVM) is unable to allocate an object due to insufficient space in the Java heap. The Java Garbage Collector (GC) cannot free up the space required for a new object, which causes a java. lang.


1 Answers

A single instance can try to acces all the memory, however NUMA regions mean that things such as GC perform badly accessing memory in another region. This is getting faster and JVM has some NUMA support but it needs to improve if you want scalability. Even so you can get 256 MB of heap and use 700 of native/direct memory without this issue. ;)

The biggest limitation if you have loads of memory is that arrays, collections and ByteBuffer (for memory mapped files) are all limited to a size of 2 billion. (2^31-1)

You can work around these problems with custom collections, but its really something Java should support IMHO.

BTW: You can buy a Dell R910 with 1 TB of memory and 24 cores/48 threads with Ubuntu for £40K.

BTW: I only have experience of JVMs up to 40 GB in size.

like image 148
Peter Lawrey Avatar answered Oct 13 '22 20:10

Peter Lawrey