What is XMs - XMx - How to control Java heap size (memory) allocation

preview_player
Показать описание
Java memory FAQ: How do I control the amount of memory my Java program uses (i.e., Java RAM usage)?

The short answer
The short answer is that you use these Java command-line parameters to help control the RAM use of application:
Use -Xmx to specify the maximum heap size
Use -Xms to specify the initial Java heap size
Use -Xss to set the Java thread stack size

Use this syntax to specify the amount of memory :

-Xms64m or -Xms64M
-Xmx1g or -Xmx1G

java -Xms512m -Xmx1024m
So java process will start with 512 MB of memory heap and can use upto 1024 MB of memory heap.
-Xmx and -Xms can be defined in different size such as kilobytes, megabytes and gigabytes.
-Xmx2048k-Xmx1024m-Xmx2g

~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Paid courses (Recorded) videos:
Рекомендации по теме
Комментарии
Автор

Very useful
I see no one provided this kind information on jenkins

bhaskar
Автор

This is simply awesome... Have seen this exception before, but never really put my head onto the solution of it.
Always thought of more optimization of code, which though should be the first approach..

But this video is extremely resourceful and knowledgeful..

arkaimps
Автор

how about specifying memory as Gi and not G ? Would Gi work ? For example memoryLimit: 3Gi please let me know.

sagaragrawal
Автор

A question,
If I allocate Xms equal to Xmx, will the garbage collector ever activate?

jamesward
Автор

Hi, how can we solve this issue on jenkins

shwetapandey