What is xmx and xms?

What is xmx and xms?

xmx?and?xms?are JVM,?Java Virtual Machine, command-line options/flags that are used by programmers to manipulate the heap size used by JVM. This allows them to optimize the speed and memory of different java applications.

About?xms

  • xms?is used to specify the initial?lower bound?of java heap memory size.
  • Default?xms?size is 1/64th of the physical memory size.
  • Format for specifying?xms:

java?-xms{Numerical?Size}{Unit}        


where?Unit?is?k/K

k/K?for kilobytes,?m/M

m/M?for megabytes, and g/G for gigabytets.

  • The numerical size must be a?whole number.
  • By default, the size is in bytes.

No alt text provided for this image

About?xmx

  • xmx?is used to specify the?upper bound?of java heap memory size.
  • Default?xms?size is 1/4th of the physical memory size.
  • Format for specifying?xms:

java?-xms{Numerical?Size}{Unit}        


where Unit is k/K for kilobytes, m/M for megabytes, and g/G for gigabytes.

  • The numerical size must be a?whole number.
  • By default, the size is in bytes.

No alt text provided for this image

Pitfalls

  • If the programmer initializes a fairly large heap size, then the?Garbage Collector?will consume more time while clearing the memory, which will slow down the program.
  • If the programmer initializes a fairly small heap size, then it is possible to run out of memory. Insufficient memory will throw the following exception:?java.lang.OutOfMemoryError: Java heap space.


Muhammad Shuja

Software Architect | Lead Software Engineer | E-commerce | Fintech

2 年

Xms?is a scaling step Xmx?is a maximum scaling limit

回复
Elsawy Eissa

Java Software Developer at Intalio-EverteamGS

3 年

Thanks Omar for sharing all this knowledge . can you add your sources in every post?

回复
Oraib Edghaim

Senior Software Engineer

3 年

Thank you for sharing all those informations

要查看或添加评论,请登录

社区洞察

其他会员也浏览了