Home > Back-end >  The JVM GC people speak
The JVM GC people speak

Time:09-16

How to write good high concurrency recycling things
Xmx4000M -Xms4000M -Xmn2000M -XX:PermSize=500M -XX:MaxPermSize=500M -Xss256K -XX:+DisableExplicitGC -XX:SurvivorRatio=1 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:CMSFullGCsBeforeCompaction=0 -XX:+CMSClassUnloadingEnabled -XX:LargePageSizeInBytes=128M -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=80 -XX:SoftRefLRUPolicyMSPerMB=0 -XX:+PrintClassHistogram -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintHeapAtGC -Xloggc:log/gc.log

CodePudding user response:

GC是垃圾收集的意思,内存处理是编程人员容易出现问题的地方,忘记或者错误的内存回收会导致程序或系统的不稳定甚至崩溃,Java提供的GC功能可以自动监测对象是否超过作用域从而达到自动回收内存的目的,Java语言没有提供释放已分配内存的显示操作方法, Java程序员不用担心内存管理,因为垃圾收集器会自动进行管理,要请求垃圾收集,可以调用下面的方法之一:System.gc() 或Runtime.getRuntime().gc() ,但JVM可以屏蔽掉显示的垃圾回收调用, 垃圾回收可以有效的防止内存泄露,有效的使用可以使用的内存,垃圾回收器通常是作为一个单独的低优先级的线程运行,不可预知的情况下对内存堆中已经死亡的或者长时间没有使用的对象进行清除和回收,程序员不能实时的调用垃圾回收器对某个对象或所有对象进行垃圾回收, 在Java诞生初期,垃圾回收是Java最大的亮点之一,因为服务器端的编程需要有效的防止内存泄露问题,然而时过境迁,如今Java的垃圾回收机制已经成为被诟病的东西,移动智能终端用户通常觉得iOS的系统比Android系统有更好的用户体验,其中一个深层次的原因就在于Android系统中垃圾回收的不可预知性,

Supplement: there are many kinds of garbage collection mechanism, including: copy a generational garbage collection, marking recycling, incremental garbage collection, the standard Java process there are both stack and heap, stack saved the original local variables, save the object to create, the Java platform to heap memory recovery and reuse of basic algorithm called tags and cleared, but the Java on the improvement, adopting "generational garbage collection type", this method will follow the Java object lifecycle will heap memory is divided into different areas, in the process of garbage collection, may move objects to different areas:

The garden of Eden (Eden) : this is the birth of the original object area, and for most objects, this is the only one that they existed area,
Survivors paradise (Survivor) : from the garden of Eden survived object will be moved to here,
Lifelong garden care (Tenured) : this is old enough to survive the object's home, the young generation collection (Minor - GC) process will not touch this place, when the young generation collection cannot put objects in the life the garden care, will trigger a full collection (Major - GC), there may also be involved in compression, in order to make room for large objects enough space,
Related to recycling the JVM parameters:

- Xms/-xmx - the initial size of the heap heap the maximum size of the
Xmn - heap size of the young generation in
- XX: - DisableExplicitGC - let System. The gc () function does not produce any
- XX: + PrintGCDetails - print the details of the GC
- XX: + PrintGCDateStamps - print GC timestamp
- XX: XX: NewSize/MaxNewSize - set up the new generation size/Cenozoic maximum size
- XX: NewRatio option - you can set the proportion of the old generation and new generation
- XX: PrintTenuringDistribution - set output after each new generation GC survivors paradise objects in the age distribution of
- XX: InitialTenuringThreshold/- XX: MaxTenuringThreshold: initial value and the maximum threshold setting old s
Survived - XX: TargetSurvivorRatio: set the target utilization

CodePudding user response:

Suggest you have a specific question to ask, such questions are nothing more than others think this post again on the network to see you, you might as well to search,

CodePudding user response:

Again, what do you want to have their own understanding, understand their own want to understand, then others can give insights on their own research, directly ask no difference with baidu
Come on ~
  • Related