1 /* |
1 /* |
2 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
55 public void run(CommandExecutor executor) { |
55 public void run(CommandExecutor executor) { |
56 OutputAnalyzer output = executor.execute("GC.class_histogram " + classHistogramArgs); |
56 OutputAnalyzer output = executor.execute("GC.class_histogram " + classHistogramArgs); |
57 |
57 |
58 /* |
58 /* |
59 * example output: |
59 * example output: |
60 * num #instances #bytes class name |
60 * num #instances #bytes class name (module) |
61 * ---------------------------------------------- |
61 * ------------------------------------------------------- |
62 * 1: 1647 1133752 [B |
62 * 1: 7991 757792 [B (java.base@9-internal) |
63 * 2: 6198 383168 [C |
63 * 2: 1811 217872 java.lang.Class (java.base@9-internal) |
64 * 3: 1464 165744 java.lang.Class |
64 * 3: 6724 215168 java.util.HashMap$Node (java.base@9-internal) |
65 * 4: 6151 147624 java.lang.String |
65 * 4: 7852 188448 java.lang.String (java.base@9-internal) |
66 * 5: 2304 73728 java.util.concurrent.ConcurrentHashMap$Node |
66 * 5: 1378 105040 [Ljava.util.HashMap$Node; (java.base@9-internal) |
67 * 6: 1199 64280 [Ljava.lang.Object; |
67 * 6: 1863 95096 [Ljava.lang.Object; (java.base@9-internal) |
|
68 |
68 * ... |
69 * ... |
69 */ |
70 */ |
70 |
71 |
71 /* Require at least one java.lang.Class */ |
72 /* Require at least one java.lang.Class */ |
72 output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Class\\s*$"); |
73 output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Class \\(java.base@\\S*\\)\\s*$"); |
73 |
74 |
74 /* Require at least one java.lang.String */ |
75 /* Require at least one java.lang.String */ |
75 output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.String\\s*$"); |
76 output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.String \\(java.base@\\S*\\)\\s*$"); |
76 |
77 |
77 /* Require at least one java.lang.Object */ |
78 /* Require at least one java.lang.Object */ |
78 output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Object\\s*$"); |
79 output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Object \\(java.base@\\S*\\)\\s*$"); |
79 |
80 |
80 /* Require at exactly one TestClass[] */ |
81 /* Require at exactly one TestClass[] */ |
81 output.shouldMatch("^\\s+\\d+:\\s+1\\s+\\d+\\s+" + |
82 output.shouldMatch("^\\s+\\d+:\\s+1\\s+\\d+\\s+" + |
82 Pattern.quote(TestClass[].class.getName()) + "\\s*$"); |
83 Pattern.quote(TestClass[].class.getName()) + "\\s*$"); |
83 |
84 |
84 /* Require at exactly 1024 TestClass */ |
85 /* Require at exactly 1024 TestClass */ |
85 output.shouldMatch("^\\s+\\d+:\\s+1024\\s+\\d+\\s+" + |
86 output.shouldMatch("^\\s+\\d+:\\s+1024\\s+\\d+\\s+" + |
86 Pattern.quote(TestClass.class.getName()) + "\\s*$"); |
87 Pattern.quote(TestClass.class.getName()) + "\\s*$"); |
87 } |
88 } |
88 |
89 |
89 @Test |
90 @Test |
90 public void jmx() { |
91 public void jmx() { |
91 run(new JMXExecutor()); |
92 run(new JMXExecutor()); |