Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/tools/HeapDumper.java @ 7402:fd74228fd5ca
8004076: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
Summary: Move _max_locals and _size_of_parameters to ConstMethod for better sharing.
Reviewed-by: coleenp, minqi, jrose
author | jiangli |
---|---|
date | Tue, 11 Dec 2012 12:41:31 -0500 |
parents | c18cbe5936b8 |
children | 38ea2efa32a7 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.tools; | |
26 | |
27 import sun.jvm.hotspot.utilities.HeapHprofBinWriter; | |
28 import java.io.IOException; | |
29 | |
30 /* | |
31 * This tool is used by the JDK jmap utility to dump the heap of the target | |
32 * process/core as a HPROF binary file. It can also be used as a standalone | |
33 * tool if required. | |
34 */ | |
35 public class HeapDumper extends Tool { | |
36 | |
37 private static String DEFAULT_DUMP_FILE = "heap.bin"; | |
38 | |
39 private String dumpFile; | |
40 | |
41 public HeapDumper(String dumpFile) { | |
42 this.dumpFile = dumpFile; | |
43 } | |
44 | |
45 protected void printFlagsUsage() { | |
46 System.out.println(" <no option>\tto dump heap to " + | |
47 DEFAULT_DUMP_FILE); | |
48 System.out.println(" -f <file>\tto dump heap to <file>"); | |
49 super.printFlagsUsage(); | |
50 } | |
51 | |
52 // use HeapHprofBinWriter to write the heap dump | |
53 public void run() { | |
54 System.out.println("Dumping heap to " + dumpFile + " ..."); | |
55 try { | |
56 new HeapHprofBinWriter().write(dumpFile); | |
57 System.out.println("Heap dump file created"); | |
58 } catch (IOException ioe) { | |
59 System.err.println(ioe.getMessage()); | |
60 } | |
61 } | |
62 | |
63 // JDK jmap utility will always invoke this tool as: | |
64 // HeapDumper -f <file> <args...> | |
65 public static void main(String args[]) { | |
66 String file = DEFAULT_DUMP_FILE; | |
67 if (args.length > 2) { | |
68 if (args[0].equals("-f")) { | |
69 file = args[1]; | |
70 String[] newargs = new String[args.length-2]; | |
71 System.arraycopy(args, 2, newargs, 0, args.length-2); | |
72 args = newargs; | |
73 } | |
74 } | |
75 | |
76 HeapDumper dumper = new HeapDumper(file); | |
77 dumper.start(args); | |
78 dumper.stop(); | |
79 } | |
80 | |
81 } |