Why is there maximum heap tuning in Java?

After reading How many characters can a Java string have? I began to wonder:

Why is there a maximum heap setting in modern JVMs? Why not just request more memory from the operating system when the heap memory runs out and the garbage collector could not free the necessary memory? Does anyone know the reason for this?

+3
source share
7 answers

I believe that it helps sandbox Java programs, i.e. stops them, taking all the memory on a physical machine. In addition, memory leaks can still occur in Java even with garbage collection, and they can be even more sophisticated than in C / C ++ from time to time.

If you really need to increase the amount of memory for your Java software, you can tweek the maximum VM size in the configuration files.

+3
source

Since you do not want the JVM to accept all possible resources on your O / S (well, in some cases you do, but in this case set the maximum heap size to the maximum of your JVM, the O / S combo can handle).

+2
source

JVM - . , , , .

+2

- , , , GC , , .

gc , .

+1

. . , RAM . , . , . , , JVM , .

+1

:

  • , .
  • , , GC .

2. , Java , Terracotta bigmemory.

+1

, , . , , , , Xmx200m , .

0

Source: https://habr.com/ru/post/1779145/


All Articles