Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

GC garbage collection

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Gc=full gc + young gc

Java jvm memory = heap memory + non-heap memory

Heap memory (- Xms-Xmx) = younger generation (- Xmn) + older generation

-Xms, initial memory allocation,-Xmx maximum memory allocation, generally set to the same value

Young generation = Eden+s0+s1

Non-heap memory = persistent generation (- XX:PermSize-XX:MaxPermSize) + codecache (- XX:reservedcodecachesize)

-XX:PermSize (initial size),-XX:MaxPermSize (maximum)

[jvm memory model diagram]

Gc: automatically detect and release memory that is no longer in use. (garbage collection)

Minor gc: fast frequency is normal, also known as young gc

Major gc: make him as frequent as possible, also known as full gc.

Persistent generation (Perm): class object used

Jvm lifecycle: ① an object that is first placed in the Eden area. If it is found that it needs to continue to be used and cannot be recycled by gc, it will be placed in the s area, and S0 and S1 will be placed at will. If ② is placed in area S0 and cannot be recycled by gc after a period of time, it will be placed in Zone S1 and ③ will not be recycled after a period of time, so it will be stored in the old generation area. ④ may be recycled by major gc or continue to survive after it has been stored in the old generation for a long time.

Jvm memory parameter settings

-Xms-Xmx is set to the same value and set to 80% of the available memory

-Xmn is set to 3max 8 of heap memory

-XX:PermSize (default is 1max 64 of physical memory),-XX:MaxPermSize (default is 1max 4 of physical memory)

Jvm common parameter configuration

-server: server mode, which must be placed before all parameters

-Xss: specify the size of each thread (no more than 1m is recommended)

-XX:SurvivorRatio: sets the size ratio of the Eden region to the s region in the younger generation

-XX:+HeapDumpOnOutOfMemoryError-heap dump will be printed when XX:HeapDumpPath=path_address:JVM crashes

-XX:+AggressiveOpts: if this parameter is enabled, your JVM will use the latest optimization technology (if any) whenever the JDK version is upgraded.

-Djava.awt.headless=true: generally put it at the end, mainly to solve the incompatibility of charts.

Type of gc

Serial GC: suitable for applications with less memory consumption with the worst performance

Parallel GC: the younger generation is multithreaded, and the older generation uses single threading

Parallel Old GC: both the younger and older generations use multithreading to collect garbage

CMS: multithreaded concurrent garbage collection, suitable for applications that can not tolerate long pauses and require fast response. It is more commonly used, preferably with-XX:+UseParNewGC.

-XX:+UseG1GC

Gc related parameters

-XX: + DisableExplicitGC: prohibit the use of System.gc

-XX:+PrintGCTimeStamps-XX:+PrintGCDetails-Xloggc: print the details log of gc recycling

-XX:+UseGCOverheadLimit: let the program end ahead of time to achieve the purpose of early warning

-XX:+UseCMSCompactAtFullCollection: destructs surviving objects to reduce memory fragmentation

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report