< prev index next >

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

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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) {


 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       printInternStringStatistics();
 133    }
 134 
 135    // Helper methods
 136 
 137    private void printGCAlgorithm(Map flagMap) {
 138        long l = getFlagValue("UseTLAB", flagMap);
 139        if (l == 1L) {
 140           System.out.println("using thread-local object allocation.");
 141        }
 142 
 143        l = getFlagValue("UseConcMarkSweepGC", flagMap);
 144        if (l == 1L) {
 145           System.out.println("Concurrent Mark-Sweep GC");
 146           return;
 147        }
 148 
 149        l = getFlagValue("UseParallelGC", flagMap);
 150        if (l == 1L) {
 151           System.out.print("Parallel GC ");
 152           l = getFlagValue("ParallelGCThreads", flagMap);
 153           System.out.println("with " + l + " thread(s)");
 154           return;
 155        }
 156 
 157        l = getFlagValue("UseG1GC", flagMap);
 158        if (l == 1L) {
 159            System.out.print("Garbage-First (G1) GC ");
 160            l = getFlagValue("ParallelGCThreads", flagMap);
 161            System.out.println("with " + l + " thread(s)");






 162            return;
 163        }
 164 
 165        System.out.println("Mark Sweep Compact GC");
 166    }
 167 
 168    private void printPSYoungGen(PSYoungGen youngGen) {
 169       System.out.println("PS Young Generation");
 170       MutableSpace eden = youngGen.edenSpace();
 171       System.out.println("Eden Space:");
 172       printMutableSpace(eden);
 173       MutableSpace from = youngGen.fromSpace();
 174       System.out.println("From Space:");
 175       printMutableSpace(from);
 176       MutableSpace to = youngGen.toSpace();
 177       System.out.println("To Space:");
 178       printMutableSpace(to);
 179    }
 180 
 181    private void printMutableSpace(MutableSpace space) {




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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.epsilon.*;
  29 import sun.jvm.hotspot.gc.g1.*;
  30 import sun.jvm.hotspot.gc.parallel.*;
  31 import sun.jvm.hotspot.gc.serial.*;
  32 import sun.jvm.hotspot.gc.shared.*;
  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) {


 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 EpsilonHeap) {
 129          EpsilonHeap eh = (EpsilonHeap) heap;
 130          printSpace(eh.space());
 131       } else {
 132          throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
 133       }
 134 
 135       System.out.println();
 136       printInternStringStatistics();
 137    }
 138 
 139    // Helper methods
 140 
 141    private void printGCAlgorithm(Map flagMap) {
 142        long l = getFlagValue("UseTLAB", flagMap);
 143        if (l == 1L) {
 144           System.out.println("using thread-local object allocation.");
 145        }
 146 
 147        l = getFlagValue("UseConcMarkSweepGC", flagMap);
 148        if (l == 1L) {
 149           System.out.println("Concurrent Mark-Sweep GC");
 150           return;
 151        }
 152 
 153        l = getFlagValue("UseParallelGC", flagMap);
 154        if (l == 1L) {
 155           System.out.print("Parallel GC ");
 156           l = getFlagValue("ParallelGCThreads", flagMap);
 157           System.out.println("with " + l + " thread(s)");
 158           return;
 159        }
 160 
 161        l = getFlagValue("UseG1GC", flagMap);
 162        if (l == 1L) {
 163            System.out.print("Garbage-First (G1) GC ");
 164            l = getFlagValue("ParallelGCThreads", flagMap);
 165            System.out.println("with " + l + " thread(s)");
 166            return;
 167        }
 168 
 169        l = getFlagValue("UseEpsilonGC", flagMap);
 170        if (l == 1L) {
 171            System.out.println("Epsilon (no-op) GC");
 172            return;
 173        }
 174 
 175        System.out.println("Mark Sweep Compact GC");
 176    }
 177 
 178    private void printPSYoungGen(PSYoungGen youngGen) {
 179       System.out.println("PS Young Generation");
 180       MutableSpace eden = youngGen.edenSpace();
 181       System.out.println("Eden Space:");
 182       printMutableSpace(eden);
 183       MutableSpace from = youngGen.fromSpace();
 184       System.out.println("From Space:");
 185       printMutableSpace(from);
 186       MutableSpace to = youngGen.toSpace();
 187       System.out.println("To Space:");
 188       printMutableSpace(to);
 189    }
 190 
 191    private void printMutableSpace(MutableSpace space) {


< prev index next >