Mercurial > hg > graal-compiler
comparison src/share/vm/services/mallocTracker.hpp @ 20553:417e3b8d04c5
8059100: SIGSEGV VirtualMemoryTracker::remove_released_region
Summary: Disallow increasing native memory tracking level
Reviewed-by: hseigel, ctornqvi, gtriantafill
author | coleenp |
---|---|
date | Fri, 10 Oct 2014 19:36:12 +0000 |
parents | dd3939fe8424 |
children | 787c9c28311f |
comparison
equal
deleted
inserted
replaced
20547:fffbcc20bf61 | 20553:417e3b8d04c5 |
---|---|
49 MemoryCounter() : _count(0), _size(0) { | 49 MemoryCounter() : _count(0), _size(0) { |
50 DEBUG_ONLY(_peak_count = 0;) | 50 DEBUG_ONLY(_peak_count = 0;) |
51 DEBUG_ONLY(_peak_size = 0;) | 51 DEBUG_ONLY(_peak_size = 0;) |
52 } | 52 } |
53 | 53 |
54 // Reset counters | |
55 void reset() { | |
56 _size = 0; | |
57 _count = 0; | |
58 DEBUG_ONLY(_peak_size = 0;) | |
59 DEBUG_ONLY(_peak_count = 0;) | |
60 } | |
61 | |
62 inline void allocate(size_t sz) { | 54 inline void allocate(size_t sz) { |
63 Atomic::add(1, (volatile MemoryCounterType*)&_count); | 55 Atomic::add(1, (volatile MemoryCounterType*)&_count); |
64 if (sz > 0) { | 56 if (sz > 0) { |
65 Atomic::add((MemoryCounterType)sz, (volatile MemoryCounterType*)&_size); | 57 Atomic::add((MemoryCounterType)sz, (volatile MemoryCounterType*)&_size); |
66 DEBUG_ONLY(_peak_size = MAX2(_peak_size, _size)); | 58 DEBUG_ONLY(_peak_size = MAX2(_peak_size, _size)); |
122 | 114 |
123 inline void record_arena_size_change(long sz) { | 115 inline void record_arena_size_change(long sz) { |
124 _arena.resize(sz); | 116 _arena.resize(sz); |
125 } | 117 } |
126 | 118 |
127 void reset() { | |
128 _malloc.reset(); | |
129 _arena.reset(); | |
130 } | |
131 | |
132 inline size_t malloc_size() const { return _malloc.size(); } | 119 inline size_t malloc_size() const { return _malloc.size(); } |
133 inline size_t malloc_count() const { return _malloc.count();} | 120 inline size_t malloc_count() const { return _malloc.count();} |
134 inline size_t arena_size() const { return _arena.size(); } | 121 inline size_t arena_size() const { return _arena.size(); } |
135 inline size_t arena_count() const { return _arena.count(); } | 122 inline size_t arena_count() const { return _arena.count(); } |
136 | 123 |
173 | 160 |
174 inline size_t thread_count() const { | 161 inline size_t thread_count() const { |
175 MallocMemorySnapshot* s = const_cast<MallocMemorySnapshot*>(this); | 162 MallocMemorySnapshot* s = const_cast<MallocMemorySnapshot*>(this); |
176 return s->by_type(mtThreadStack)->malloc_count(); | 163 return s->by_type(mtThreadStack)->malloc_count(); |
177 } | 164 } |
178 | |
179 void reset(); | |
180 | 165 |
181 void copy_to(MallocMemorySnapshot* s) { | 166 void copy_to(MallocMemorySnapshot* s) { |
182 s->_tracking_header = _tracking_header; | 167 s->_tracking_header = _tracking_header; |
183 for (int index = 0; index < mt_number_of_types; index ++) { | 168 for (int index = 0; index < mt_number_of_types; index ++) { |
184 s->_malloc[index] = _malloc[index]; | 169 s->_malloc[index] = _malloc[index]; |
236 } | 221 } |
237 | 222 |
238 // The memory used by malloc tracking headers | 223 // The memory used by malloc tracking headers |
239 static inline size_t tracking_overhead() { | 224 static inline size_t tracking_overhead() { |
240 return as_snapshot()->malloc_overhead()->size(); | 225 return as_snapshot()->malloc_overhead()->size(); |
241 } | |
242 | |
243 // Reset all counters to zero | |
244 static void reset() { | |
245 as_snapshot()->reset(); | |
246 } | 226 } |
247 | 227 |
248 static MallocMemorySnapshot* as_snapshot() { | 228 static MallocMemorySnapshot* as_snapshot() { |
249 return (MallocMemorySnapshot*)_snapshot; | 229 return (MallocMemorySnapshot*)_snapshot; |
250 } | 230 } |