zoukankan      html  css  js  c++  java
  • Java Memory Basic

    转自: http://www.blogjava.net/justinchen/archive/2009/justinchen/archive/2009/01/08/248738.html

    GC and Full GC

    The garbage collector (GC) detects garbage, defined as objects that are no longer reachable, then reclaims it and makes space available to the running program. The GC typically works in a stop-the-world fashion -- that is, it freezes the heap when working.

    The above diagram describes the layout of HotSpot VM Heap and it consists of three parts: perm generation, old generation and new/yang generation. The perm generation is basically for class loading. Next are the old and young generation. The young generation is further broken up into three spaces: Eden, Survivor Space 1 (SS#1) and Survivor Space 2 (SS#2). 

    Garbage Collection1. When you have a new object, the object gets created in Eden space.
    2. So after running for a while, Eden space will fill up.a minor garbage collection occurs, in which all the objects alive in Eden are copied over to SS#1. Eden is then empty and ready to receive new objects.
    3. After the minor GC, objects are allocated to Eden again. After a time, the Eden space fills up again, and another minor GC occurs. The objects surviving in SS#1 and Eden are copied to SS#2, and both SS#1 and Eden are reset. Although objects are frequently recopied, either from Eden or from one SS to another, at any one time, only Eden and one SS are operating.
    4. Every time an object moves from Eden to SS or from one SS to another, a counter and its header is incremented. By default, if the copying occurs 16 times or more, the HotSpot VM stops copying them and moves them to the old generation.
    5. If an object can't be created in Eden, it goes directly to the old generation. Moving an object from SS to the old generation because of its age is called tenuring. Because of tenuring, the old generation becomes full over time. This calls for garbage collection of the old generation, which is called a full GC. A full GC is a compaction process that is slower than a minor GC.
  • 相关阅读:
    java1200_060_把数字格式化为货币字符串
    ccf_201712-02
    ccf_201712-01
    算法笔记-----单源最短路径之Bellman-Ford算法
    算法笔记-----贪心算法----加里比海盗船--最优装载问题
    算法笔记-----最优二叉搜索树
    SHTSC2017酱油记
    并不能来一发50AC
    【bzoj4514】: [Sdoi2016]数字配对 图论-费用流
    【bzoj1066】: [SCOI2007]蜥蜴 图论-最大流
  • 原文地址:https://www.cnblogs.com/reynold-lei/p/3422531.html
Copyright © 2011-2022 走看看