javax4u / customer-meetings

2 stars 0 forks source link

Define the java heap #85

Open apoorvpandey-ap opened 2 years ago

jkumar0021 commented 2 years ago

image

image

Recommended Java Settings Fedora 6 requires Java 11. The following Java HotSpot VM Options are recommended for running Fedora 6:

-Djava.awt.headless=true -Dfile.encoding=UTF-8 -Xms1G -Xmx2G -XX:+UseG1GC -XX:+DisableExplicitGC For Linux JVMs, see: https://docs.oracle.com/en/java/javase/11/tools/java.html

-Djava.awt.headless=true Headless mode is a system configuration in which the display device, keyboard, or mouse is lacking. Sounds unexpected, but actually you can perform different operations in this mode, even with graphic data. -Dfile.encoding=UTF-8
Tell the JVM to use UTF-8 as an encoding for text files to be more platform independent -Xms1G Set the initial Java Heap memory size to 1 Gigabyte -Xmx2G Set the maximal Java Heap memory size to 2 Gigabytes -XX:+UseG1GC Enables the use of the garbage-first (G1) garbage collector. It is a server-style garbage collector, targeted for multiprocessor machines with a large amount of RAM. It meets GC pause time goals with high probability, while maintaining good throughput. The G1 collector is recommended for applications requiring large heaps (sizes of around 6 GB or larger) with limited GC latency requirements (stable and predictable pause time below 0.5 seconds). -XX:+DisableExplicitGC Disable calls to System.gc(), JVM still performs garbage collection when necessary. Other considerations -XX:MaxMetaspaceSize=1G If you expect to be redeploying the Fedora instance often, supplying this setting is helpful to prevent OutOfMemory errors. It sets the maximum size of native memory that can be allocated for class metadata to 1 Gigabyte. -XX:MaxNewSize=1G Set the maximal amount of memory which will be allowed for the young generation of objects in memory to 1 Gigabyte. Increasing this value will decrease the frequency of minor garbage collections, but increase the frequency of major.

javax4u commented 2 years ago

Another type of memory is stack memory , programmers can face error related to it by using infinite loop. One example is call back function.

Stack Self

image


About Heap memory subtypes @jkumar0021 has described in above comment.

image

You can see the continuously increasing graph of HeapMemory because object are getting creating infinitely, It just matter of time this JVM will throw java.lang.OutOfMemoryError: Java heap space error

image