Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JVM Memory Defaults

Tags:

java

memory

jvm

What is the default Xms and Xmx settings for the Sun JVM (v 1.4*) if those values are not specified at startup?

like image 427
Edward Q. Bridges Avatar asked Jul 20 '09 16:07

Edward Q. Bridges


People also ask

What is the default JVM memory size?

The Java™ virtual machine (JVM) heap size setting directly relates to how many server instances can be started within a dynamic cluster on a specific node. You might need to modify the JVM heap size setting based on your environment configuration. The default value is 256 MB.

What is the default heap size of JVM 8?

So default maximum jvm heap size is: 256mb or 1gb or 32gb depending on VM, above.

What memory does JVM use?

The JVM divides its memory into two main categories: heap memory and non-heap memory. Heap memory is the part with which people are typically the most familiar. It's where objects that are created by the application are stored. They remain there until they are no longer referenced and are garbage collected.


2 Answers

As documented:

  • Xmx: default 64M
  • Xms: default 2M

That's for Linux, but I've checked and the values are the same for Windows and Solaris too. Don't rely on that being the case for other versions or options though. In particular, the choice of server or client VM depends on operating system, at least in later versions.

Another piece of documentation

like image 174
Jon Skeet Avatar answered Sep 24 '22 17:09

Jon Skeet


From Sun's tooldocs:

-Xmsn Specify the initial size, in bytes, of the memory allocation pool. This value must be a multiple of 1024 greater than 1MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 2MB. Examples:

           -Xms6291456
           -Xms6144k
           -Xms6m

-Xmxn Specify the maximum size, in bytes, of the memory allocation pool. This value must a multiple of 1024 greater than 2MB. Append the letter k or K to indicate kilobytes, or m or M to indicate megabytes. The default value is 64MB. Examples:

           -Xmx83886080
           -Xmx81920k
           -Xmx80m

So 2MB and 64MB.

(The link above is for the 1.5 docs, but you can download the 1.4 docs, and they say the same thing.)

like image 41
Laurence Gonsalves Avatar answered Sep 26 '22 17:09

Laurence Gonsalves