< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.tools;
  26 
  27 import java.util.*;
  28 import sun.jvm.hotspot.gc.g1.*;
  29 import sun.jvm.hotspot.gc.parallel.*;
  30 import sun.jvm.hotspot.gc.serial.*;
  31 import sun.jvm.hotspot.gc.shared.*;

  32 import sun.jvm.hotspot.debugger.JVMDebugger;
  33 import sun.jvm.hotspot.memory.*;
  34 import sun.jvm.hotspot.oops.*;
  35 import sun.jvm.hotspot.runtime.*;
  36 
  37 public class HeapSummary extends Tool {
  38 
  39    public HeapSummary() {
  40       super();
  41    }
  42 
  43    public HeapSummary(JVMDebugger d) {
  44       super(d);
  45    }
  46 
  47    public static void main(String[] args) {
  48       HeapSummary hs = new HeapSummary();
  49       hs.execute(args);
  50    }
  51 


 107                printSpace(to);
 108             } else {
 109                System.out.println(gen.name() + ":");
 110                printGen(gen);
 111             }
 112          }
 113       } else if (heap instanceof G1CollectedHeap) {
 114           printG1HeapSummary((G1CollectedHeap)heap);
 115       } else if (heap instanceof ParallelScavengeHeap) {
 116          ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
 117          PSYoungGen youngGen = psh.youngGen();
 118          printPSYoungGen(youngGen);
 119 
 120          PSOldGen oldGen = psh.oldGen();
 121          long oldFree = oldGen.capacity() - oldGen.used();
 122          System.out.println("PS Old Generation");
 123          printValMB("capacity = ", oldGen.capacity());
 124          printValMB("used     = ", oldGen.used());
 125          printValMB("free     = ", oldFree);
 126          System.out.println(alignment + (double)oldGen.used() * 100.0 / oldGen.capacity() + "% used");



 127       } else {
 128          throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
 129       }
 130 
 131       System.out.println();
 132    }
 133 
 134    // Helper methods
 135 
 136    private void printGCAlgorithm(Map flagMap) {
 137        long l = getFlagValue("UseTLAB", flagMap);
 138        if (l == 1L) {
 139           System.out.println("using thread-local object allocation.");
 140        }
 141 
 142        l = getFlagValue("UseConcMarkSweepGC", flagMap);
 143        if (l == 1L) {
 144           System.out.println("Concurrent Mark-Sweep GC");
 145           return;
 146        }
 147 
 148        l = getFlagValue("UseParallelGC", flagMap);
 149        if (l == 1L) {
 150           System.out.print("Parallel GC ");
 151           l = getFlagValue("ParallelGCThreads", flagMap);
 152           System.out.println("with " + l + " thread(s)");
 153           return;
 154        }
 155 
 156        l = getFlagValue("UseG1GC", flagMap);
 157        if (l == 1L) {
 158            System.out.print("Garbage-First (G1) GC ");








 159            l = getFlagValue("ParallelGCThreads", flagMap);
 160            System.out.println("with " + l + " thread(s)");
 161            return;
 162        }
 163 
 164        System.out.println("Mark Sweep Compact GC");
 165    }
 166 
 167    private void printPSYoungGen(PSYoungGen youngGen) {
 168       System.out.println("PS Young Generation");
 169       MutableSpace eden = youngGen.edenSpace();
 170       System.out.println("Eden Space:");
 171       printMutableSpace(eden);
 172       MutableSpace from = youngGen.fromSpace();
 173       System.out.println("From Space:");
 174       printMutableSpace(from);
 175       MutableSpace to = youngGen.toSpace();
 176       System.out.println("To Space:");
 177       printMutableSpace(to);
 178    }




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 package sun.jvm.hotspot.tools;
  26 
  27 import java.util.*;
  28 import sun.jvm.hotspot.gc.g1.*;
  29 import sun.jvm.hotspot.gc.parallel.*;
  30 import sun.jvm.hotspot.gc.serial.*;
  31 import sun.jvm.hotspot.gc.shared.*;
  32 import sun.jvm.hotspot.gc.z.*;
  33 import sun.jvm.hotspot.debugger.JVMDebugger;
  34 import sun.jvm.hotspot.memory.*;
  35 import sun.jvm.hotspot.oops.*;
  36 import sun.jvm.hotspot.runtime.*;
  37 
  38 public class HeapSummary extends Tool {
  39 
  40    public HeapSummary() {
  41       super();
  42    }
  43 
  44    public HeapSummary(JVMDebugger d) {
  45       super(d);
  46    }
  47 
  48    public static void main(String[] args) {
  49       HeapSummary hs = new HeapSummary();
  50       hs.execute(args);
  51    }
  52 


 108                printSpace(to);
 109             } else {
 110                System.out.println(gen.name() + ":");
 111                printGen(gen);
 112             }
 113          }
 114       } else if (heap instanceof G1CollectedHeap) {
 115           printG1HeapSummary((G1CollectedHeap)heap);
 116       } else if (heap instanceof ParallelScavengeHeap) {
 117          ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
 118          PSYoungGen youngGen = psh.youngGen();
 119          printPSYoungGen(youngGen);
 120 
 121          PSOldGen oldGen = psh.oldGen();
 122          long oldFree = oldGen.capacity() - oldGen.used();
 123          System.out.println("PS Old Generation");
 124          printValMB("capacity = ", oldGen.capacity());
 125          printValMB("used     = ", oldGen.used());
 126          printValMB("free     = ", oldFree);
 127          System.out.println(alignment + (double)oldGen.used() * 100.0 / oldGen.capacity() + "% used");
 128       } else if (heap instanceof ZCollectedHeap) {
 129          ZCollectedHeap zheap = (ZCollectedHeap) heap;
 130          zheap.printOn(System.out);
 131       } else {
 132          throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
 133       }
 134 
 135       System.out.println();
 136    }
 137 
 138    // Helper methods
 139 
 140    private void printGCAlgorithm(Map flagMap) {
 141        long l = getFlagValue("UseTLAB", flagMap);
 142        if (l == 1L) {
 143           System.out.println("using thread-local object allocation.");
 144        }
 145 
 146        l = getFlagValue("UseConcMarkSweepGC", flagMap);
 147        if (l == 1L) {
 148           System.out.println("Concurrent Mark-Sweep GC");
 149           return;
 150        }
 151 
 152        l = getFlagValue("UseParallelGC", flagMap);
 153        if (l == 1L) {
 154           System.out.print("Parallel GC ");
 155           l = getFlagValue("ParallelGCThreads", flagMap);
 156           System.out.println("with " + l + " thread(s)");
 157           return;
 158        }
 159 
 160        l = getFlagValue("UseG1GC", flagMap);
 161        if (l == 1L) {
 162            System.out.print("Garbage-First (G1) GC ");
 163            l = getFlagValue("ParallelGCThreads", flagMap);
 164            System.out.println("with " + l + " thread(s)");
 165            return;
 166        }
 167 
 168        l = getFlagValue("UseZGC", flagMap);
 169        if (l == 1L) {
 170            System.out.print("ZGC ");
 171            l = getFlagValue("ParallelGCThreads", flagMap);
 172            System.out.println("with " + l + " thread(s)");
 173            return;
 174        }
 175 
 176        System.out.println("Mark Sweep Compact GC");
 177    }
 178 
 179    private void printPSYoungGen(PSYoungGen youngGen) {
 180       System.out.println("PS Young Generation");
 181       MutableSpace eden = youngGen.edenSpace();
 182       System.out.println("Eden Space:");
 183       printMutableSpace(eden);
 184       MutableSpace from = youngGen.fromSpace();
 185       System.out.println("From Space:");
 186       printMutableSpace(from);
 187       MutableSpace to = youngGen.toSpace();
 188       System.out.println("To Space:");
 189       printMutableSpace(to);
 190    }


< prev index next >