24 |
24 |
25 #ifndef SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP |
25 #ifndef SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP |
26 #define SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP |
26 #define SHARE_JFR_LEAKPROFILER_SAMPLING_OBJECTSAMPLE_HPP |
27 |
27 |
28 #include "jfr/recorder/checkpoint/jfrCheckpointBlob.hpp" |
28 #include "jfr/recorder/checkpoint/jfrCheckpointBlob.hpp" |
|
29 #include "jfr/recorder/stacktrace/jfrStackTrace.hpp" |
29 #include "jfr/utilities/jfrAllocation.hpp" |
30 #include "jfr/utilities/jfrAllocation.hpp" |
30 #include "jfr/utilities/jfrTime.hpp" |
31 #include "jfr/utilities/jfrTime.hpp" |
31 #include "jfr/utilities/jfrTypes.hpp" |
32 #include "jfr/utilities/jfrTypes.hpp" |
32 #include "memory/allocation.hpp" |
33 #include "memory/allocation.hpp" |
33 #include "oops/oop.hpp" |
34 #include "oops/oop.hpp" |
34 #include "utilities/ticks.hpp" |
35 #include "utilities/ticks.hpp" |
|
36 |
35 /* |
37 /* |
36 * Handle for diagnosing Java memory leaks. |
38 * Handle for diagnosing Java memory leaks. |
37 * |
39 * |
38 * The class tracks the time the object was |
40 * The class tracks the time the object was |
39 * allocated, the thread and the stack trace. |
41 * allocated, the thread and the stack trace. |
40 */ |
42 */ |
41 class ObjectSample : public JfrCHeapObj { |
43 class ObjectSample : public JfrCHeapObj { |
|
44 friend class CheckpointInstall; |
|
45 friend class ObjectResolver; |
|
46 friend class ObjectSampleCheckpoint; |
42 friend class ObjectSampler; |
47 friend class ObjectSampler; |
43 friend class SampleList; |
48 friend class SampleList; |
44 private: |
49 private: |
45 ObjectSample* _next; |
50 ObjectSample* _next; |
46 ObjectSample* _previous; |
51 ObjectSample* _previous; |
|
52 mutable const JfrStackTrace* _stack_trace; |
47 JfrCheckpointBlobHandle _thread_cp; |
53 JfrCheckpointBlobHandle _thread_cp; |
48 JfrCheckpointBlobHandle _klass_cp; |
54 JfrCheckpointBlobHandle _klass_cp; |
49 oop _object; |
55 oop _object; |
50 Ticks _allocation_time; |
56 Ticks _allocation_time; |
51 traceid _stack_trace_id; |
57 traceid _stack_trace_id; |
52 traceid _thread_id; |
58 traceid _thread_id; |
|
59 mutable traceid _klass_id; |
53 int _index; |
60 int _index; |
54 size_t _span; |
61 size_t _span; |
55 size_t _allocated; |
62 size_t _allocated; |
56 size_t _heap_used_at_last_gc; |
63 size_t _heap_used_at_last_gc; |
57 unsigned int _stack_trace_hash; |
64 unsigned int _stack_trace_hash; |
70 } |
77 } |
71 } |
78 } |
72 |
79 |
73 void reset() { |
80 void reset() { |
74 set_stack_trace_id(0); |
81 set_stack_trace_id(0); |
75 set_stack_trace_hash(0), |
82 set_stack_trace_hash(0); |
|
83 _klass_id = 0; |
76 release_references(); |
84 release_references(); |
77 _dead = false; |
85 _dead = false; |
|
86 } |
|
87 |
|
88 ~ObjectSample() { |
|
89 if (_stack_trace != NULL) { |
|
90 delete _stack_trace; |
|
91 } |
78 } |
92 } |
79 |
93 |
80 public: |
94 public: |
81 ObjectSample() : _next(NULL), |
95 ObjectSample() : _next(NULL), |
82 _previous(NULL), |
96 _previous(NULL), |
|
97 _stack_trace(NULL), |
83 _thread_cp(), |
98 _thread_cp(), |
84 _klass_cp(), |
99 _klass_cp(), |
85 _object(NULL), |
100 _object(NULL), |
86 _allocation_time(), |
101 _allocation_time(), |
87 _stack_trace_id(0), |
102 _stack_trace_id(0), |
88 _thread_id(0), |
103 _thread_id(0), |
|
104 _klass_id(0), |
89 _index(0), |
105 _index(0), |
90 _span(0), |
106 _span(0), |
91 _allocated(0), |
107 _allocated(0), |
92 _heap_used_at_last_gc(0), |
108 _heap_used_at_last_gc(0), |
93 _stack_trace_hash(0), |
109 _stack_trace_hash(0), |
172 |
188 |
173 size_t heap_used_at_last_gc() const { |
189 size_t heap_used_at_last_gc() const { |
174 return _heap_used_at_last_gc; |
190 return _heap_used_at_last_gc; |
175 } |
191 } |
176 |
192 |
177 bool has_stack_trace() const { |
193 bool has_stack_trace_id() const { |
178 return stack_trace_id() != 0; |
194 return stack_trace_id() != 0; |
179 } |
195 } |
180 |
196 |
181 traceid stack_trace_id() const { |
197 traceid stack_trace_id() const { |
182 return _stack_trace_id; |
198 return _stack_trace_id; |
190 return _stack_trace_hash; |
206 return _stack_trace_hash; |
191 } |
207 } |
192 |
208 |
193 void set_stack_trace_hash(unsigned int hash) { |
209 void set_stack_trace_hash(unsigned int hash) { |
194 _stack_trace_hash = hash; |
210 _stack_trace_hash = hash; |
|
211 } |
|
212 |
|
213 const JfrStackTrace* stack_trace() const { |
|
214 return _stack_trace; |
|
215 } |
|
216 |
|
217 void set_stack_trace(const JfrStackTrace* trace) const { |
|
218 _stack_trace = trace; |
195 } |
219 } |
196 |
220 |
197 bool has_thread() const { |
221 bool has_thread() const { |
198 return _thread_id != 0; |
222 return _thread_id != 0; |
199 } |
223 } |