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 #ifndef SHARE_SERVICES_MEMREPORTER_HPP
26 #define SHARE_SERVICES_MEMREPORTER_HPP
27
28 #if INCLUDE_NMT
29
30 #include "memory/metaspace.hpp"
31 #include "oops/instanceKlass.hpp"
32 #include "services/memBaseline.hpp"
33 #include "services/nmtCommon.hpp"
34 #include "services/mallocTracker.hpp"
35 #include "services/virtualMemoryTracker.hpp"
36
37 /*
38 * Base class that provides helpers
39 */
40 class MemReporterBase : public StackObj {
41 private:
42 size_t _scale; // report in this scale
43 outputStream* _output; // destination
44
45 public:
46 MemReporterBase(outputStream* out = NULL, size_t scale = K)
47 : _scale(scale) {
48 _output = (out == NULL) ? tty : out;
49 }
50
97 size_t _instance_class_count;
98 size_t _array_class_count;
99
100 public:
101 // This constructor is for normal reporting from a recent baseline.
102 MemSummaryReporter(MemBaseline& baseline, outputStream* output,
103 size_t scale = K) : MemReporterBase(output, scale),
104 _malloc_snapshot(baseline.malloc_memory_snapshot()),
105 _vm_snapshot(baseline.virtual_memory_snapshot()),
106 _instance_class_count(baseline.instance_class_count()),
107 _array_class_count(baseline.array_class_count()) { }
108
109
110 // Generate summary report
111 virtual void report();
112 private:
113 // Report summary for each memory type
114 void report_summary_of_type(MEMFLAGS type, MallocMemory* malloc_memory,
115 VirtualMemory* virtual_memory);
116
117 void report_metadata(Metaspace::MetadataType type) const;
118 };
119
120 /*
121 * The class is for generating detail tracking report.
122 */
123 class MemDetailReporter : public MemSummaryReporter {
124 private:
125 MemBaseline& _baseline;
126
127 public:
128 MemDetailReporter(MemBaseline& baseline, outputStream* output, size_t scale = K) :
129 MemSummaryReporter(baseline, output, scale),
130 _baseline(baseline) { }
131
132 // Generate detail report.
133 // The report contains summary and detail sections.
134 virtual void report() {
135 MemSummaryReporter::report();
136 report_virtual_memory_map();
137 report_detail();
172 virtual void report_diff();
173
174 private:
175 // report the comparison of each memory type
176 void diff_summary_of_type(MEMFLAGS type,
177 const MallocMemory* early_malloc, const VirtualMemory* early_vm,
178 const MetaspaceSnapshot* early_ms,
179 const MallocMemory* current_malloc, const VirtualMemory* current_vm,
180 const MetaspaceSnapshot* current_ms) const;
181
182 protected:
183 void print_malloc_diff(size_t current_amount, size_t current_count,
184 size_t early_amount, size_t early_count, MEMFLAGS flags) const;
185 void print_virtual_memory_diff(size_t current_reserved, size_t current_committed,
186 size_t early_reserved, size_t early_committed) const;
187 void print_arena_diff(size_t current_amount, size_t current_count,
188 size_t early_amount, size_t early_count) const;
189
190 void print_metaspace_diff(const MetaspaceSnapshot* current_ms,
191 const MetaspaceSnapshot* early_ms) const;
192 void print_metaspace_diff(Metaspace::MetadataType type,
193 const MetaspaceSnapshot* current_ms, const MetaspaceSnapshot* early_ms) const;
194 };
195
196 /*
197 * The class is for generating detail comparison report.
198 * It compares current memory baseline against an early baseline,
199 * both baselines have to be detail baseline.
200 */
201 class MemDetailDiffReporter : public MemSummaryDiffReporter {
202 public:
203 MemDetailDiffReporter(MemBaseline& early_baseline, MemBaseline& current_baseline,
204 outputStream* output, size_t scale = K) :
205 MemSummaryDiffReporter(early_baseline, current_baseline, output, scale) { }
206
207 // Generate detail comparison report
208 virtual void report_diff();
209
210 // Malloc allocation site comparison
211 void diff_malloc_sites() const;
212 // Virutal memory reservation site comparison
|
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 #ifndef SHARE_SERVICES_MEMREPORTER_HPP
26 #define SHARE_SERVICES_MEMREPORTER_HPP
27
28 #if INCLUDE_NMT
29
30 #include "memory/metaspace/metaspaceEnums.hpp"
31 #include "oops/instanceKlass.hpp"
32 #include "services/memBaseline.hpp"
33 #include "services/nmtCommon.hpp"
34 #include "services/mallocTracker.hpp"
35 #include "services/virtualMemoryTracker.hpp"
36
37 /*
38 * Base class that provides helpers
39 */
40 class MemReporterBase : public StackObj {
41 private:
42 size_t _scale; // report in this scale
43 outputStream* _output; // destination
44
45 public:
46 MemReporterBase(outputStream* out = NULL, size_t scale = K)
47 : _scale(scale) {
48 _output = (out == NULL) ? tty : out;
49 }
50
97 size_t _instance_class_count;
98 size_t _array_class_count;
99
100 public:
101 // This constructor is for normal reporting from a recent baseline.
102 MemSummaryReporter(MemBaseline& baseline, outputStream* output,
103 size_t scale = K) : MemReporterBase(output, scale),
104 _malloc_snapshot(baseline.malloc_memory_snapshot()),
105 _vm_snapshot(baseline.virtual_memory_snapshot()),
106 _instance_class_count(baseline.instance_class_count()),
107 _array_class_count(baseline.array_class_count()) { }
108
109
110 // Generate summary report
111 virtual void report();
112 private:
113 // Report summary for each memory type
114 void report_summary_of_type(MEMFLAGS type, MallocMemory* malloc_memory,
115 VirtualMemory* virtual_memory);
116
117 void report_metadata(metaspace::MetadataType type) const;
118 };
119
120 /*
121 * The class is for generating detail tracking report.
122 */
123 class MemDetailReporter : public MemSummaryReporter {
124 private:
125 MemBaseline& _baseline;
126
127 public:
128 MemDetailReporter(MemBaseline& baseline, outputStream* output, size_t scale = K) :
129 MemSummaryReporter(baseline, output, scale),
130 _baseline(baseline) { }
131
132 // Generate detail report.
133 // The report contains summary and detail sections.
134 virtual void report() {
135 MemSummaryReporter::report();
136 report_virtual_memory_map();
137 report_detail();
172 virtual void report_diff();
173
174 private:
175 // report the comparison of each memory type
176 void diff_summary_of_type(MEMFLAGS type,
177 const MallocMemory* early_malloc, const VirtualMemory* early_vm,
178 const MetaspaceSnapshot* early_ms,
179 const MallocMemory* current_malloc, const VirtualMemory* current_vm,
180 const MetaspaceSnapshot* current_ms) const;
181
182 protected:
183 void print_malloc_diff(size_t current_amount, size_t current_count,
184 size_t early_amount, size_t early_count, MEMFLAGS flags) const;
185 void print_virtual_memory_diff(size_t current_reserved, size_t current_committed,
186 size_t early_reserved, size_t early_committed) const;
187 void print_arena_diff(size_t current_amount, size_t current_count,
188 size_t early_amount, size_t early_count) const;
189
190 void print_metaspace_diff(const MetaspaceSnapshot* current_ms,
191 const MetaspaceSnapshot* early_ms) const;
192 void print_metaspace_diff(metaspace::MetadataType type,
193 const MetaspaceSnapshot* current_ms, const MetaspaceSnapshot* early_ms) const;
194 };
195
196 /*
197 * The class is for generating detail comparison report.
198 * It compares current memory baseline against an early baseline,
199 * both baselines have to be detail baseline.
200 */
201 class MemDetailDiffReporter : public MemSummaryDiffReporter {
202 public:
203 MemDetailDiffReporter(MemBaseline& early_baseline, MemBaseline& current_baseline,
204 outputStream* output, size_t scale = K) :
205 MemSummaryDiffReporter(early_baseline, current_baseline, output, scale) { }
206
207 // Generate detail comparison report
208 virtual void report_diff();
209
210 // Malloc allocation site comparison
211 void diff_malloc_sites() const;
212 // Virutal memory reservation site comparison
|