JVM virtual machine GC

Time:2020-10-13

GC

JVM virtual machine GC

During GC, the JVM does not recycle the three regions uniformly. Most of the recycling is in the new generation

  • Cenozoic era
  • From, to
  • Old age

There are two types of GC: light GC (normal GC) and heavy GC (Global GC)

When an object has gone through GC for 15 times and has not died, it will enter the pension area

The number of GC generations set by JVM: – XX: maxtenuringthread = 5

Through this parameter, you can set the time of entering the old age

JVM virtual machine GC

Eden:from:to = 8:1:1

  • What is the memory model of the JVM?
  • What are the partitions in the heap? Eden, from, to
  • GC algorithm? Mark clearing, label compression, copy algorithm, reference count, how to use
  • When do light GC and heavy GC occur respectively

Reference counting method:

JVM virtual machine GC

Replication algorithm:

It’s aimed at Eden, from and to regions and young people

What is the difference between from and to?

Who is empty and who is to

  1. Every GC will move Eden’s living objects to the surviving area: once the Eden area is GC, it will be empty!
  2. The from and to fields are alternate. The objects in the from area will be copied into to, and then the from field will be empty. At this point, from becomes to and to becomes from

JVM virtual machine GC

  • Benefit: no memory fragmentation
  • Disadvantages: wasted memory space: half more space is always empty to, assuming the object is 100% alive (in extreme cases) oom

    The best use scenario of replication algorithm: low survival of objects; use of new area

Mark removal method

JVM virtual machine GC

  • Disadvantages: two scans seriously waste time or produce fragments.
  • Advantage: no extra space required

Label compression

Re Optimization:

More mobile costs

JVM virtual machine GC

##Summary

Memory efficiency: copy algorithm > mark clear method > mark compression algorithm (time complexity)

Memory uniformity: copy algorithm = mark compression > mark clear method

Memory utilization: Mark compression = mark clear > copy algorithm

There is no best algorithm, only the most appropriate algorithm – > GC: generational collection algorithm

Young generation:

  • Low survival rate: replication algorithm

    Old age:
  • Large area: high survival rate
  • Mixed implementation of mark clearing and label compression

JVM

Recommended Today

Blog based on beego, go blog

Go Blog A beego based development, can quickly create personal blog, CMS system Include functions see Official website of go bloggo-blog.cn Demo siteleechan.online Update log time function January 23, 2020 New top post function February 2, 2020 New custom navigation function February 4, 2020 New site announcement function February 6, 2020 New link module February […]