src/share/vm/services/memTracker.cpp

Thu, 18 Jul 2013 12:05:32 -0700

author
dcubed
date
Thu, 18 Jul 2013 12:05:32 -0700
changeset 5425
248c459b2b75
parent 5403
90d6c221d4e5
parent 5410
c9a5fab39234
child 6876
710a3c8b516e
child 6911
ce8f6bb717c9
permissions
-rw-r--r--

Merge

zgu@3900 1 /*
zgu@4890 2 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
zgu@3900 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
zgu@3900 4 *
zgu@3900 5 * This code is free software; you can redistribute it and/or modify it
zgu@3900 6 * under the terms of the GNU General Public License version 2 only, as
zgu@3900 7 * published by the Free Software Foundation.
zgu@3900 8 *
zgu@3900 9 * This code is distributed in the hope that it will be useful, but WITHOUT
zgu@3900 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
zgu@3900 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
zgu@3900 12 * version 2 for more details (a copy is included in the LICENSE file that
zgu@3900 13 * accompanied this code).
zgu@3900 14 *
zgu@3900 15 * You should have received a copy of the GNU General Public License version
zgu@3900 16 * 2 along with this work; if not, write to the Free Software Foundation,
zgu@3900 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
zgu@3900 18 *
zgu@3900 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
zgu@3900 20 * or visit www.oracle.com if you need additional information or have any
zgu@3900 21 * questions.
zgu@3900 22 *
zgu@3900 23 */
zgu@3900 24 #include "precompiled.hpp"
zgu@3900 25
zgu@4400 26 #include "oops/instanceKlass.hpp"
zgu@3900 27 #include "runtime/atomic.hpp"
zgu@3900 28 #include "runtime/interfaceSupport.hpp"
zgu@3900 29 #include "runtime/mutexLocker.hpp"
zgu@3900 30 #include "runtime/safepoint.hpp"
zgu@3900 31 #include "runtime/threadCritical.hpp"
ctornqvi@4512 32 #include "runtime/vm_operations.hpp"
zgu@3900 33 #include "services/memPtr.hpp"
zgu@3900 34 #include "services/memReporter.hpp"
zgu@3900 35 #include "services/memTracker.hpp"
zgu@3900 36 #include "utilities/decoder.hpp"
jprovino@5188 37 #include "utilities/defaultStream.hpp"
zgu@3900 38 #include "utilities/globalDefinitions.hpp"
zgu@3900 39
zgu@3900 40 bool NMT_track_callsite = false;
zgu@3900 41
zgu@3900 42 // walk all 'known' threads at NMT sync point, and collect their recorders
zgu@3900 43 void SyncThreadRecorderClosure::do_thread(Thread* thread) {
zgu@3900 44 assert(SafepointSynchronize::is_at_safepoint(), "Safepoint required");
zgu@3900 45 if (thread->is_Java_thread()) {
zgu@3900 46 JavaThread* javaThread = (JavaThread*)thread;
zgu@3900 47 MemRecorder* recorder = javaThread->get_recorder();
zgu@3900 48 if (recorder != NULL) {
zgu@3900 49 MemTracker::enqueue_pending_recorder(recorder);
zgu@3900 50 javaThread->set_recorder(NULL);
zgu@3900 51 }
zgu@3900 52 }
zgu@3900 53 _thread_count ++;
zgu@3900 54 }
zgu@3900 55
zgu@3900 56
zgu@4927 57 MemRecorder* volatile MemTracker::_global_recorder = NULL;
zgu@3900 58 MemSnapshot* MemTracker::_snapshot = NULL;
zgu@3900 59 MemBaseline MemTracker::_baseline;
zgu@3936 60 Mutex* MemTracker::_query_lock = NULL;
zgu@4927 61 MemRecorder* volatile MemTracker::_merge_pending_queue = NULL;
zgu@4927 62 MemRecorder* volatile MemTracker::_pooled_recorders = NULL;
zgu@3900 63 MemTrackWorker* MemTracker::_worker_thread = NULL;
zgu@3900 64 int MemTracker::_sync_point_skip_count = 0;
zgu@3900 65 MemTracker::NMTLevel MemTracker::_tracking_level = MemTracker::NMT_off;
zgu@3900 66 volatile MemTracker::NMTStates MemTracker::_state = NMT_uninited;
zgu@3900 67 MemTracker::ShutdownReason MemTracker::_reason = NMT_shutdown_none;
zgu@3900 68 int MemTracker::_thread_count = 255;
zgu@3900 69 volatile jint MemTracker::_pooled_recorder_count = 0;
ctornqvi@4512 70 volatile unsigned long MemTracker::_processing_generation = 0;
ctornqvi@4512 71 volatile bool MemTracker::_worker_thread_idle = false;
zgu@5272 72 volatile jint MemTracker::_pending_op_count = 0;
zgu@4810 73 volatile bool MemTracker::_slowdown_calling_thread = false;
zgu@3900 74 debug_only(intx MemTracker::_main_thread_tid = 0;)
zgu@3994 75 NOT_PRODUCT(volatile jint MemTracker::_pending_recorder_count = 0;)
zgu@3900 76
zgu@3900 77 void MemTracker::init_tracking_options(const char* option_line) {
zgu@3900 78 _tracking_level = NMT_off;
zgu@4291 79 if (strcmp(option_line, "=summary") == 0) {
zgu@3900 80 _tracking_level = NMT_summary;
zgu@4291 81 } else if (strcmp(option_line, "=detail") == 0) {
jprovino@5188 82 // detail relies on a stack-walking ability that may not
jprovino@5188 83 // be available depending on platform and/or compiler flags
jprovino@5402 84 #if PLATFORM_NATIVE_STACK_WALKING_SUPPORTED
jprovino@5188 85 _tracking_level = NMT_detail;
jprovino@5402 86 #else
jprovino@5188 87 jio_fprintf(defaultStream::error_stream(),
jprovino@5402 88 "NMT detail is not supported on this platform. Using NMT summary instead.\n");
jprovino@5188 89 _tracking_level = NMT_summary;
jprovino@5402 90 #endif
zgu@4291 91 } else if (strcmp(option_line, "=off") != 0) {
zgu@4291 92 vm_exit_during_initialization("Syntax error, expecting -XX:NativeMemoryTracking=[off|summary|detail]", NULL);
zgu@3900 93 }
zgu@3900 94 }
zgu@3900 95
zgu@3900 96 // first phase of bootstrapping, when VM is still in single-threaded mode.
zgu@3900 97 void MemTracker::bootstrap_single_thread() {
zgu@3900 98 if (_tracking_level > NMT_off) {
zgu@3900 99 assert(_state == NMT_uninited, "wrong state");
zgu@3900 100
zgu@3900 101 // NMT is not supported with UseMallocOnly is on. NMT can NOT
zgu@3900 102 // handle the amount of malloc data without significantly impacting
zgu@3900 103 // runtime performance when this flag is on.
zgu@3900 104 if (UseMallocOnly) {
zgu@3900 105 shutdown(NMT_use_malloc_only);
zgu@3900 106 return;
zgu@3900 107 }
zgu@3900 108
zgu@3936 109 _query_lock = new (std::nothrow) Mutex(Monitor::max_nonleaf, "NMT_queryLock");
zgu@3936 110 if (_query_lock == NULL) {
zgu@3936 111 shutdown(NMT_out_of_memory);
zgu@3936 112 return;
zgu@3936 113 }
zgu@3936 114
zgu@3900 115 debug_only(_main_thread_tid = os::current_thread_id();)
zgu@3900 116 _state = NMT_bootstrapping_single_thread;
zgu@3900 117 NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
zgu@3900 118 }
zgu@3900 119 }
zgu@3900 120
zgu@3900 121 // second phase of bootstrapping, when VM is about to or already entered multi-theaded mode.
zgu@3900 122 void MemTracker::bootstrap_multi_thread() {
zgu@3900 123 if (_tracking_level > NMT_off && _state == NMT_bootstrapping_single_thread) {
zgu@3900 124 // create nmt lock for multi-thread execution
zgu@3900 125 assert(_main_thread_tid == os::current_thread_id(), "wrong thread");
zgu@3900 126 _state = NMT_bootstrapping_multi_thread;
zgu@3900 127 NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
zgu@3900 128 }
zgu@3900 129 }
zgu@3900 130
zgu@3900 131 // fully start nmt
zgu@3900 132 void MemTracker::start() {
zgu@3900 133 // Native memory tracking is off from command line option
zgu@3900 134 if (_tracking_level == NMT_off || shutdown_in_progress()) return;
zgu@3900 135
zgu@3900 136 assert(_main_thread_tid == os::current_thread_id(), "wrong thread");
zgu@3900 137 assert(_state == NMT_bootstrapping_multi_thread, "wrong state");
zgu@3900 138
zgu@3900 139 _snapshot = new (std::nothrow)MemSnapshot();
zgu@4890 140 if (_snapshot != NULL) {
zgu@4927 141 if (!_snapshot->out_of_memory() && start_worker(_snapshot)) {
zgu@3900 142 _state = NMT_started;
zgu@3900 143 NMT_track_callsite = (_tracking_level == NMT_detail && can_walk_stack());
zgu@3900 144 return;
zgu@3900 145 }
zgu@4890 146
zgu@4890 147 delete _snapshot;
zgu@4890 148 _snapshot = NULL;
zgu@3900 149 }
zgu@3900 150
zgu@3900 151 // fail to start native memory tracking, shut it down
zgu@3900 152 shutdown(NMT_initialization);
zgu@3900 153 }
zgu@3900 154
zgu@3900 155 /**
zgu@3900 156 * Shutting down native memory tracking.
zgu@3900 157 * We can not shutdown native memory tracking immediately, so we just
zgu@3900 158 * setup shutdown pending flag, every native memory tracking component
zgu@3900 159 * should orderly shut itself down.
zgu@3900 160 *
zgu@3900 161 * The shutdown sequences:
zgu@3900 162 * 1. MemTracker::shutdown() sets MemTracker to shutdown pending state
zgu@3900 163 * 2. Worker thread calls MemTracker::final_shutdown(), which transites
zgu@3900 164 * MemTracker to final shutdown state.
zgu@3900 165 * 3. At sync point, MemTracker does final cleanup, before sets memory
zgu@3900 166 * tracking level to off to complete shutdown.
zgu@3900 167 */
zgu@3900 168 void MemTracker::shutdown(ShutdownReason reason) {
zgu@3900 169 if (_tracking_level == NMT_off) return;
zgu@3900 170
zgu@3900 171 if (_state <= NMT_bootstrapping_single_thread) {
zgu@3900 172 // we still in single thread mode, there is not contention
zgu@3900 173 _state = NMT_shutdown_pending;
zgu@3900 174 _reason = reason;
zgu@3900 175 } else {
zgu@3900 176 // we want to know who initialized shutdown
zgu@3900 177 if ((jint)NMT_started == Atomic::cmpxchg((jint)NMT_shutdown_pending,
zgu@3900 178 (jint*)&_state, (jint)NMT_started)) {
zgu@3900 179 _reason = reason;
zgu@3900 180 }
zgu@3900 181 }
zgu@3900 182 }
zgu@3900 183
zgu@3900 184 // final phase of shutdown
zgu@3900 185 void MemTracker::final_shutdown() {
zgu@3900 186 // delete all pending recorders and pooled recorders
zgu@3900 187 delete_all_pending_recorders();
zgu@3900 188 delete_all_pooled_recorders();
zgu@3900 189
zgu@3900 190 {
zgu@3900 191 // shared baseline and snapshot are the only objects needed to
zgu@3900 192 // create query results
zgu@3936 193 MutexLockerEx locker(_query_lock, true);
zgu@3900 194 // cleanup baseline data and snapshot
zgu@3900 195 _baseline.clear();
zgu@3900 196 delete _snapshot;
zgu@3900 197 _snapshot = NULL;
zgu@3900 198 }
zgu@3900 199
zgu@3900 200 // shutdown shared decoder instance, since it is only
zgu@3900 201 // used by native memory tracking so far.
zgu@3900 202 Decoder::shutdown();
zgu@3900 203
zgu@3900 204 MemTrackWorker* worker = NULL;
zgu@3900 205 {
zgu@3900 206 ThreadCritical tc;
zgu@3900 207 // can not delete worker inside the thread critical
zgu@3900 208 if (_worker_thread != NULL && Thread::current() == _worker_thread) {
zgu@3900 209 worker = _worker_thread;
zgu@3900 210 _worker_thread = NULL;
zgu@3900 211 }
zgu@3900 212 }
zgu@3900 213 if (worker != NULL) {
zgu@3900 214 delete worker;
zgu@3900 215 }
zgu@3900 216 _state = NMT_final_shutdown;
zgu@3900 217 }
zgu@3900 218
zgu@3900 219 // delete all pooled recorders
zgu@3900 220 void MemTracker::delete_all_pooled_recorders() {
zgu@3900 221 // free all pooled recorders
zgu@4927 222 MemRecorder* volatile cur_head = _pooled_recorders;
zgu@3900 223 if (cur_head != NULL) {
zgu@3900 224 MemRecorder* null_ptr = NULL;
zgu@3900 225 while (cur_head != NULL && (void*)cur_head != Atomic::cmpxchg_ptr((void*)null_ptr,
zgu@3900 226 (void*)&_pooled_recorders, (void*)cur_head)) {
zgu@3900 227 cur_head = _pooled_recorders;
zgu@3900 228 }
zgu@3900 229 if (cur_head != NULL) {
zgu@3900 230 delete cur_head;
zgu@3900 231 _pooled_recorder_count = 0;
zgu@3900 232 }
zgu@3900 233 }
zgu@3900 234 }
zgu@3900 235
zgu@3900 236 // delete all recorders in pending queue
zgu@3900 237 void MemTracker::delete_all_pending_recorders() {
zgu@3900 238 // free all pending recorders
zgu@3900 239 MemRecorder* pending_head = get_pending_recorders();
zgu@3900 240 if (pending_head != NULL) {
zgu@3900 241 delete pending_head;
zgu@3900 242 }
zgu@3900 243 }
zgu@3900 244
zgu@3900 245 /*
zgu@3900 246 * retrieve per-thread recorder of specified thread.
zgu@3900 247 * if thread == NULL, it means global recorder
zgu@3900 248 */
zgu@3900 249 MemRecorder* MemTracker::get_thread_recorder(JavaThread* thread) {
zgu@3900 250 if (shutdown_in_progress()) return NULL;
zgu@3900 251
zgu@3900 252 MemRecorder* rc;
zgu@3900 253 if (thread == NULL) {
zgu@3900 254 rc = _global_recorder;
zgu@3900 255 } else {
zgu@3900 256 rc = thread->get_recorder();
zgu@3900 257 }
zgu@3900 258
zgu@3900 259 if (rc != NULL && rc->is_full()) {
zgu@3900 260 enqueue_pending_recorder(rc);
zgu@3900 261 rc = NULL;
zgu@3900 262 }
zgu@3900 263
zgu@3900 264 if (rc == NULL) {
zgu@3900 265 rc = get_new_or_pooled_instance();
zgu@3900 266 if (thread == NULL) {
zgu@3900 267 _global_recorder = rc;
zgu@3900 268 } else {
zgu@3900 269 thread->set_recorder(rc);
zgu@3900 270 }
zgu@3900 271 }
zgu@3900 272 return rc;
zgu@3900 273 }
zgu@3900 274
zgu@3900 275 /*
zgu@3900 276 * get a per-thread recorder from pool, or create a new one if
zgu@3900 277 * there is not one available.
zgu@3900 278 */
zgu@3900 279 MemRecorder* MemTracker::get_new_or_pooled_instance() {
zgu@3900 280 MemRecorder* cur_head = const_cast<MemRecorder*> (_pooled_recorders);
zgu@3900 281 if (cur_head == NULL) {
zgu@3900 282 MemRecorder* rec = new (std::nothrow)MemRecorder();
zgu@3900 283 if (rec == NULL || rec->out_of_memory()) {
zgu@3900 284 shutdown(NMT_out_of_memory);
zgu@3900 285 if (rec != NULL) {
zgu@3900 286 delete rec;
zgu@3900 287 rec = NULL;
zgu@3900 288 }
zgu@3900 289 }
zgu@3900 290 return rec;
zgu@3900 291 } else {
zgu@3900 292 MemRecorder* next_head = cur_head->next();
zgu@3900 293 if ((void*)cur_head != Atomic::cmpxchg_ptr((void*)next_head, (void*)&_pooled_recorders,
zgu@3900 294 (void*)cur_head)) {
zgu@3900 295 return get_new_or_pooled_instance();
zgu@3900 296 }
zgu@3900 297 cur_head->set_next(NULL);
zgu@3900 298 Atomic::dec(&_pooled_recorder_count);
ctornqvi@4512 299 cur_head->set_generation();
zgu@3900 300 return cur_head;
zgu@3900 301 }
zgu@3900 302 }
zgu@3900 303
zgu@3900 304 /*
zgu@3900 305 * retrieve all recorders in pending queue, and empty the queue
zgu@3900 306 */
zgu@3900 307 MemRecorder* MemTracker::get_pending_recorders() {
zgu@3900 308 MemRecorder* cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
zgu@3900 309 MemRecorder* null_ptr = NULL;
zgu@3900 310 while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)null_ptr, (void*)&_merge_pending_queue,
zgu@3900 311 (void*)cur_head)) {
zgu@3900 312 cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
zgu@3900 313 }
zgu@3994 314 NOT_PRODUCT(Atomic::store(0, &_pending_recorder_count));
zgu@3900 315 return cur_head;
zgu@3900 316 }
zgu@3900 317
zgu@3900 318 /*
zgu@3900 319 * release a recorder to recorder pool.
zgu@3900 320 */
zgu@3900 321 void MemTracker::release_thread_recorder(MemRecorder* rec) {
zgu@3900 322 assert(rec != NULL, "null recorder");
zgu@3900 323 // we don't want to pool too many recorders
zgu@3900 324 rec->set_next(NULL);
zgu@3900 325 if (shutdown_in_progress() || _pooled_recorder_count > _thread_count * 2) {
zgu@3900 326 delete rec;
zgu@3900 327 return;
zgu@3900 328 }
zgu@3900 329
zgu@3900 330 rec->clear();
zgu@3900 331 MemRecorder* cur_head = const_cast<MemRecorder*>(_pooled_recorders);
zgu@3900 332 rec->set_next(cur_head);
zgu@3900 333 while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)rec, (void*)&_pooled_recorders,
zgu@3900 334 (void*)cur_head)) {
zgu@3900 335 cur_head = const_cast<MemRecorder*>(_pooled_recorders);
zgu@3900 336 rec->set_next(cur_head);
zgu@3900 337 }
zgu@3900 338 Atomic::inc(&_pooled_recorder_count);
zgu@3900 339 }
zgu@3900 340
zgu@3900 341 // write a record to proper recorder. No lock can be taken from this method
zgu@3900 342 // down.
zgu@5272 343 void MemTracker::write_tracking_record(address addr, MEMFLAGS flags,
zgu@5272 344 size_t size, jint seq, address pc, JavaThread* thread) {
zgu@3900 345
zgu@3935 346 MemRecorder* rc = get_thread_recorder(thread);
zgu@3900 347 if (rc != NULL) {
zgu@5272 348 rc->record(addr, flags, size, seq, pc);
zgu@3900 349 }
zgu@3900 350 }
zgu@3900 351
zgu@3900 352 /**
zgu@3900 353 * enqueue a recorder to pending queue
zgu@3900 354 */
zgu@3900 355 void MemTracker::enqueue_pending_recorder(MemRecorder* rec) {
zgu@3900 356 assert(rec != NULL, "null recorder");
zgu@3900 357
zgu@3900 358 // we are shutting down, so just delete it
zgu@3900 359 if (shutdown_in_progress()) {
zgu@3900 360 rec->set_next(NULL);
zgu@3900 361 delete rec;
zgu@3900 362 return;
zgu@3900 363 }
zgu@3900 364
zgu@3900 365 MemRecorder* cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
zgu@3900 366 rec->set_next(cur_head);
zgu@3900 367 while ((void*)cur_head != Atomic::cmpxchg_ptr((void*)rec, (void*)&_merge_pending_queue,
zgu@3900 368 (void*)cur_head)) {
zgu@3900 369 cur_head = const_cast<MemRecorder*>(_merge_pending_queue);
zgu@3900 370 rec->set_next(cur_head);
zgu@3900 371 }
zgu@3994 372 NOT_PRODUCT(Atomic::inc(&_pending_recorder_count);)
zgu@3900 373 }
zgu@3900 374
zgu@3900 375 /*
zgu@3900 376 * The method is called at global safepoint
zgu@3900 377 * during it synchronization process.
zgu@3900 378 * 1. enqueue all JavaThreads' per-thread recorders
zgu@3900 379 * 2. enqueue global recorder
zgu@3900 380 * 3. retrieve all pending recorders
zgu@3900 381 * 4. reset global sequence number generator
zgu@3900 382 * 5. call worker's sync
zgu@3900 383 */
zgu@3900 384 #define MAX_SAFEPOINTS_TO_SKIP 128
zgu@3900 385 #define SAFE_SEQUENCE_THRESHOLD 30
zgu@3900 386 #define HIGH_GENERATION_THRESHOLD 60
zgu@4810 387 #define MAX_RECORDER_THREAD_RATIO 30
zgu@5410 388 #define MAX_RECORDER_PER_THREAD 100
zgu@3900 389
zgu@3900 390 void MemTracker::sync() {
zgu@3900 391 assert(_tracking_level > NMT_off, "NMT is not enabled");
zgu@3900 392 assert(SafepointSynchronize::is_at_safepoint(), "Safepoint required");
zgu@3900 393
zgu@3900 394 // Some GC tests hit large number of safepoints in short period of time
zgu@3900 395 // without meaningful activities. We should prevent going to
zgu@3900 396 // sync point in these cases, which can potentially exhaust generation buffer.
zgu@3900 397 // Here is the factots to determine if we should go into sync point:
zgu@3900 398 // 1. not to overflow sequence number
zgu@3900 399 // 2. if we are in danger to overflow generation buffer
zgu@3900 400 // 3. how many safepoints we already skipped sync point
zgu@3900 401 if (_state == NMT_started) {
zgu@3900 402 // worker thread is not ready, no one can manage generation
zgu@3900 403 // buffer, so skip this safepoint
zgu@3900 404 if (_worker_thread == NULL) return;
zgu@3900 405
zgu@3900 406 if (_sync_point_skip_count < MAX_SAFEPOINTS_TO_SKIP) {
zgu@3900 407 int per_seq_in_use = SequenceGenerator::peek() * 100 / max_jint;
zgu@3900 408 int per_gen_in_use = _worker_thread->generations_in_use() * 100 / MAX_GENERATIONS;
zgu@3900 409 if (per_seq_in_use < SAFE_SEQUENCE_THRESHOLD && per_gen_in_use >= HIGH_GENERATION_THRESHOLD) {
zgu@3900 410 _sync_point_skip_count ++;
zgu@3900 411 return;
zgu@3900 412 }
zgu@3900 413 }
zgu@3900 414 {
zgu@3900 415 // This method is running at safepoint, with ThreadCritical lock,
zgu@3900 416 // it should guarantee that NMT is fully sync-ed.
zgu@3900 417 ThreadCritical tc;
zgu@3935 418
zgu@5272 419 // We can NOT execute NMT sync-point if there are pending tracking ops.
zgu@5272 420 if (_pending_op_count == 0) {
zgu@5272 421 SequenceGenerator::reset();
zgu@5272 422 _sync_point_skip_count = 0;
zgu@4193 423
zgu@5272 424 // walk all JavaThreads to collect recorders
zgu@5272 425 SyncThreadRecorderClosure stc;
zgu@5272 426 Threads::threads_do(&stc);
zgu@3935 427
zgu@5272 428 _thread_count = stc.get_thread_count();
zgu@5272 429 MemRecorder* pending_recorders = get_pending_recorders();
zgu@3935 430
zgu@5272 431 if (_global_recorder != NULL) {
zgu@5272 432 _global_recorder->set_next(pending_recorders);
zgu@5272 433 pending_recorders = _global_recorder;
zgu@5272 434 _global_recorder = NULL;
zgu@5272 435 }
zgu@5272 436
zgu@5272 437 // see if NMT has too many outstanding recorder instances, it usually
zgu@5272 438 // means that worker thread is lagging behind in processing them.
zgu@5272 439 if (!AutoShutdownNMT) {
zgu@5272 440 _slowdown_calling_thread = (MemRecorder::_instance_count > MAX_RECORDER_THREAD_RATIO * _thread_count);
zgu@5410 441 } else {
zgu@5410 442 // If auto shutdown is on, enforce MAX_RECORDER_PER_THREAD threshold to prevent OOM
zgu@5410 443 if (MemRecorder::_instance_count >= _thread_count * MAX_RECORDER_PER_THREAD) {
zgu@5410 444 shutdown(NMT_out_of_memory);
zgu@5410 445 }
zgu@5272 446 }
zgu@5272 447
zgu@5272 448 // check _worker_thread with lock to avoid racing condition
zgu@5272 449 if (_worker_thread != NULL) {
zgu@5272 450 _worker_thread->at_sync_point(pending_recorders, InstanceKlass::number_of_instance_classes());
zgu@5272 451 }
zgu@5272 452 assert(SequenceGenerator::peek() == 1, "Should not have memory activities during sync-point");
zgu@5272 453 } else {
zgu@5272 454 _sync_point_skip_count ++;
zgu@3900 455 }
zgu@3900 456 }
zgu@3900 457 }
zgu@3900 458
zgu@3900 459 // now, it is the time to shut whole things off
zgu@3900 460 if (_state == NMT_final_shutdown) {
zgu@3900 461 // walk all JavaThreads to delete all recorders
zgu@3900 462 SyncThreadRecorderClosure stc;
zgu@3900 463 Threads::threads_do(&stc);
zgu@3900 464 // delete global recorder
zgu@3900 465 {
zgu@3900 466 ThreadCritical tc;
zgu@3900 467 if (_global_recorder != NULL) {
zgu@3900 468 delete _global_recorder;
zgu@3900 469 _global_recorder = NULL;
zgu@3900 470 }
zgu@3900 471 }
zgu@3935 472 MemRecorder* pending_recorders = get_pending_recorders();
zgu@3935 473 if (pending_recorders != NULL) {
zgu@3935 474 delete pending_recorders;
zgu@3935 475 }
zgu@3935 476 // try at a later sync point to ensure MemRecorder instance drops to zero to
zgu@3935 477 // completely shutdown NMT
zgu@3935 478 if (MemRecorder::_instance_count == 0) {
zgu@3935 479 _state = NMT_shutdown;
zgu@3935 480 _tracking_level = NMT_off;
zgu@3935 481 }
zgu@3900 482 }
zgu@3900 483 }
zgu@3900 484
zgu@3900 485 /*
zgu@3900 486 * Start worker thread.
zgu@3900 487 */
zgu@4927 488 bool MemTracker::start_worker(MemSnapshot* snapshot) {
zgu@4927 489 assert(_worker_thread == NULL && _snapshot != NULL, "Just Check");
zgu@4927 490 _worker_thread = new (std::nothrow) MemTrackWorker(snapshot);
zgu@4927 491 if (_worker_thread == NULL) {
zgu@4927 492 return false;
zgu@4927 493 } else if (_worker_thread->has_error()) {
zgu@4927 494 delete _worker_thread;
zgu@4927 495 _worker_thread = NULL;
zgu@3900 496 return false;
zgu@3900 497 }
zgu@3900 498 _worker_thread->start();
zgu@3900 499 return true;
zgu@3900 500 }
zgu@3900 501
zgu@3900 502 /*
zgu@3900 503 * We need to collect a JavaThread's per-thread recorder
zgu@3900 504 * before it exits.
zgu@3900 505 */
zgu@3900 506 void MemTracker::thread_exiting(JavaThread* thread) {
zgu@3900 507 if (is_on()) {
zgu@3900 508 MemRecorder* rec = thread->get_recorder();
zgu@3900 509 if (rec != NULL) {
zgu@3900 510 enqueue_pending_recorder(rec);
zgu@3900 511 thread->set_recorder(NULL);
zgu@3900 512 }
zgu@3900 513 }
zgu@3900 514 }
zgu@3900 515
zgu@3900 516 // baseline current memory snapshot
zgu@3900 517 bool MemTracker::baseline() {
zgu@4980 518 MutexLocker lock(_query_lock);
zgu@3900 519 MemSnapshot* snapshot = get_snapshot();
zgu@3900 520 if (snapshot != NULL) {
zgu@3900 521 return _baseline.baseline(*snapshot, false);
zgu@3900 522 }
zgu@3900 523 return false;
zgu@3900 524 }
zgu@3900 525
zgu@3900 526 // print memory usage from current snapshot
zgu@3900 527 bool MemTracker::print_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) {
zgu@3900 528 MemBaseline baseline;
zgu@4980 529 MutexLocker lock(_query_lock);
zgu@3900 530 MemSnapshot* snapshot = get_snapshot();
zgu@3900 531 if (snapshot != NULL && baseline.baseline(*snapshot, summary_only)) {
zgu@3900 532 BaselineReporter reporter(out, unit);
zgu@3900 533 reporter.report_baseline(baseline, summary_only);
zgu@3900 534 return true;
zgu@3900 535 }
zgu@3900 536 return false;
zgu@3900 537 }
zgu@3900 538
ctornqvi@4512 539 // Whitebox API for blocking until the current generation of NMT data has been merged
ctornqvi@4512 540 bool MemTracker::wbtest_wait_for_data_merge() {
ctornqvi@4512 541 // NMT can't be shutdown while we're holding _query_lock
zgu@4980 542 MutexLocker lock(_query_lock);
ctornqvi@4512 543 assert(_worker_thread != NULL, "Invalid query");
ctornqvi@4512 544 // the generation at query time, so NMT will spin till this generation is processed
ctornqvi@4512 545 unsigned long generation_at_query_time = SequenceGenerator::current_generation();
ctornqvi@4512 546 unsigned long current_processing_generation = _processing_generation;
ctornqvi@4512 547 // if generation counter overflown
ctornqvi@4512 548 bool generation_overflown = (generation_at_query_time < current_processing_generation);
ctornqvi@4512 549 long generations_to_wrap = MAX_UNSIGNED_LONG - current_processing_generation;
ctornqvi@4512 550 // spin
ctornqvi@4512 551 while (!shutdown_in_progress()) {
ctornqvi@4512 552 if (!generation_overflown) {
ctornqvi@4512 553 if (current_processing_generation > generation_at_query_time) {
ctornqvi@4512 554 return true;
ctornqvi@4512 555 }
ctornqvi@4512 556 } else {
ctornqvi@4512 557 assert(generations_to_wrap >= 0, "Sanity check");
ctornqvi@4512 558 long current_generations_to_wrap = MAX_UNSIGNED_LONG - current_processing_generation;
ctornqvi@4512 559 assert(current_generations_to_wrap >= 0, "Sanity check");
ctornqvi@4512 560 // to overflow an unsigned long should take long time, so to_wrap check should be sufficient
ctornqvi@4512 561 if (current_generations_to_wrap > generations_to_wrap &&
ctornqvi@4512 562 current_processing_generation > generation_at_query_time) {
ctornqvi@4512 563 return true;
ctornqvi@4512 564 }
ctornqvi@4512 565 }
ctornqvi@4512 566
ctornqvi@4512 567 // if worker thread is idle, but generation is not advancing, that means
ctornqvi@4512 568 // there is not safepoint to let NMT advance generation, force one.
ctornqvi@4512 569 if (_worker_thread_idle) {
ctornqvi@4512 570 VM_ForceSafepoint vfs;
ctornqvi@4512 571 VMThread::execute(&vfs);
ctornqvi@4512 572 }
ctornqvi@4512 573 MemSnapshot* snapshot = get_snapshot();
ctornqvi@4512 574 if (snapshot == NULL) {
ctornqvi@4512 575 return false;
ctornqvi@4512 576 }
ctornqvi@4512 577 snapshot->wait(1000);
ctornqvi@4512 578 current_processing_generation = _processing_generation;
ctornqvi@4512 579 }
ctornqvi@4512 580 // We end up here if NMT is shutting down before our data has been merged
ctornqvi@4512 581 return false;
ctornqvi@4512 582 }
ctornqvi@4512 583
zgu@3900 584 // compare memory usage between current snapshot and baseline
zgu@3900 585 bool MemTracker::compare_memory_usage(BaselineOutputer& out, size_t unit, bool summary_only) {
zgu@4980 586 MutexLocker lock(_query_lock);
zgu@3900 587 if (_baseline.baselined()) {
zgu@3900 588 MemBaseline baseline;
zgu@3900 589 MemSnapshot* snapshot = get_snapshot();
zgu@3900 590 if (snapshot != NULL && baseline.baseline(*snapshot, summary_only)) {
zgu@3900 591 BaselineReporter reporter(out, unit);
zgu@3900 592 reporter.diff_baselines(baseline, _baseline, summary_only);
zgu@3900 593 return true;
zgu@3900 594 }
zgu@3900 595 }
zgu@3900 596 return false;
zgu@3900 597 }
zgu@3900 598
zgu@3900 599 #ifndef PRODUCT
zgu@3900 600 void MemTracker::walk_stack(int toSkip, char* buf, int len) {
zgu@3900 601 int cur_len = 0;
zgu@3900 602 char tmp[1024];
zgu@3900 603 address pc;
zgu@3900 604
zgu@3900 605 while (cur_len < len) {
zgu@3900 606 pc = os::get_caller_pc(toSkip + 1);
zgu@3900 607 if (pc != NULL && os::dll_address_to_function_name(pc, tmp, sizeof(tmp), NULL)) {
zgu@3900 608 jio_snprintf(&buf[cur_len], (len - cur_len), "%s\n", tmp);
zgu@3900 609 cur_len = (int)strlen(buf);
zgu@3900 610 } else {
zgu@3900 611 buf[cur_len] = '\0';
zgu@3900 612 break;
zgu@3900 613 }
zgu@3900 614 toSkip ++;
zgu@3900 615 }
zgu@3900 616 }
zgu@3900 617
zgu@3900 618 void MemTracker::print_tracker_stats(outputStream* st) {
zgu@3900 619 st->print_cr("\nMemory Tracker Stats:");
zgu@3900 620 st->print_cr("\tMax sequence number = %d", SequenceGenerator::max_seq_num());
zgu@3900 621 st->print_cr("\tthead count = %d", _thread_count);
zgu@3900 622 st->print_cr("\tArena instance = %d", Arena::_instance_count);
zgu@3900 623 st->print_cr("\tpooled recorder count = %d", _pooled_recorder_count);
zgu@3900 624 st->print_cr("\tqueued recorder count = %d", _pending_recorder_count);
zgu@3900 625 st->print_cr("\tmemory recorder instance count = %d", MemRecorder::_instance_count);
zgu@3900 626 if (_worker_thread != NULL) {
zgu@3900 627 st->print_cr("\tWorker thread:");
zgu@3900 628 st->print_cr("\t\tSync point count = %d", _worker_thread->_sync_point_count);
zgu@3900 629 st->print_cr("\t\tpending recorder count = %d", _worker_thread->count_pending_recorders());
zgu@3900 630 st->print_cr("\t\tmerge count = %d", _worker_thread->_merge_count);
zgu@3900 631 } else {
zgu@3900 632 st->print_cr("\tWorker thread is not started");
zgu@3900 633 }
zgu@3900 634 st->print_cr(" ");
zgu@3900 635
zgu@3900 636 if (_snapshot != NULL) {
zgu@3900 637 _snapshot->print_snapshot_stats(st);
zgu@3900 638 } else {
zgu@3900 639 st->print_cr("No snapshot");
zgu@3900 640 }
zgu@3900 641 }
zgu@3900 642 #endif
zgu@3900 643
zgu@5272 644
zgu@5272 645 // Tracker Implementation
zgu@5272 646
zgu@5272 647 /*
zgu@5272 648 * Create a tracker.
zgu@5272 649 * This is a fairly complicated constructor, as it has to make two important decisions:
zgu@5272 650 * 1) Does it need to take ThreadCritical lock to write tracking record
zgu@5272 651 * 2) Does it need to pre-reserve a sequence number for the tracking record
zgu@5272 652 *
zgu@5272 653 * The rules to determine if ThreadCritical is needed:
zgu@5272 654 * 1. When nmt is in single-threaded bootstrapping mode, no lock is needed as VM
zgu@5272 655 * still in single thread mode.
zgu@5272 656 * 2. For all threads other than JavaThread, ThreadCritical is needed
zgu@5272 657 * to write to recorders to global recorder.
zgu@5272 658 * 3. For JavaThreads that are no longer visible by safepoint, also
zgu@5272 659 * need to take ThreadCritical and records are written to global
zgu@5272 660 * recorders, since these threads are NOT walked by Threads.do_thread().
zgu@5272 661 * 4. JavaThreads that are running in safepoint-safe states do not stop
zgu@5272 662 * for safepoints, ThreadCritical lock should be taken to write
zgu@5272 663 * memory records.
zgu@5272 664 * 5. JavaThreads that are running in VM state do not need any lock and
zgu@5272 665 * records are written to per-thread recorders.
zgu@5272 666 * 6. For a thread has yet to attach VM 'Thread', they need to take
zgu@5272 667 * ThreadCritical to write to global recorder.
zgu@5272 668 *
zgu@5272 669 * The memory operations that need pre-reserve sequence numbers:
zgu@5272 670 * The memory operations that "release" memory blocks and the
zgu@5272 671 * operations can fail, need to pre-reserve sequence number. They
zgu@5272 672 * are realloc, uncommit and release.
zgu@5272 673 *
zgu@5272 674 * The reason for pre-reserve sequence number, is to prevent race condition:
zgu@5272 675 * Thread 1 Thread 2
zgu@5272 676 * <release>
zgu@5272 677 * <allocate>
zgu@5272 678 * <write allocate record>
zgu@5272 679 * <write release record>
zgu@5272 680 * if Thread 2 happens to obtain the memory address Thread 1 just released,
zgu@5272 681 * then NMT can mistakenly report the memory is free.
zgu@5272 682 *
zgu@5272 683 * Noticeably, free() does not need pre-reserve sequence number, because the call
zgu@5272 684 * does not fail, so we can alway write "release" record before the memory is actaully
zgu@5272 685 * freed.
zgu@5272 686 *
zgu@5272 687 * For realloc, uncommit and release, following coding pattern should be used:
zgu@5272 688 *
zgu@5272 689 * MemTracker::Tracker tkr = MemTracker::get_realloc_tracker();
zgu@5272 690 * ptr = ::realloc(...);
zgu@5272 691 * if (ptr == NULL) {
zgu@5272 692 * tkr.record(...)
zgu@5272 693 * } else {
zgu@5272 694 * tkr.discard();
zgu@5272 695 * }
zgu@5272 696 *
zgu@5272 697 * MemTracker::Tracker tkr = MemTracker::get_virtual_memory_uncommit_tracker();
zgu@5272 698 * if (uncommit(...)) {
zgu@5272 699 * tkr.record(...);
zgu@5272 700 * } else {
zgu@5272 701 * tkr.discard();
zgu@5272 702 * }
zgu@5272 703 *
zgu@5272 704 * MemTracker::Tracker tkr = MemTracker::get_virtual_memory_release_tracker();
zgu@5272 705 * if (release(...)) {
zgu@5272 706 * tkr.record(...);
zgu@5272 707 * } else {
zgu@5272 708 * tkr.discard();
zgu@5272 709 * }
zgu@5272 710 *
zgu@5272 711 * Since pre-reserved sequence number is only good for the generation that it is acquired,
zgu@5272 712 * when there is pending Tracker that reserved sequence number, NMT sync-point has
zgu@5272 713 * to be skipped to prevent from advancing generation. This is done by inc and dec
zgu@5272 714 * MemTracker::_pending_op_count, when MemTracker::_pending_op_count > 0, NMT sync-point is skipped.
zgu@5272 715 * Not all pre-reservation of sequence number will increment pending op count. For JavaThreads
zgu@5272 716 * that honor safepoints, safepoint can not occur during the memory operations, so the
zgu@5272 717 * pre-reserved sequence number won't cross the generation boundry.
zgu@5272 718 */
zgu@5272 719 MemTracker::Tracker::Tracker(MemoryOperation op, Thread* thr) {
zgu@5272 720 _op = NoOp;
zgu@5272 721 _seq = 0;
zgu@5272 722 if (MemTracker::is_on()) {
zgu@5272 723 _java_thread = NULL;
zgu@5272 724 _op = op;
zgu@5272 725
zgu@5272 726 // figure out if ThreadCritical lock is needed to write this operation
zgu@5272 727 // to MemTracker
zgu@5272 728 if (MemTracker::is_single_threaded_bootstrap()) {
zgu@5272 729 thr = NULL;
zgu@5272 730 } else if (thr == NULL) {
zgu@5272 731 // don't use Thread::current(), since it is possible that
zgu@5272 732 // the calling thread has yet to attach to VM 'Thread',
zgu@5272 733 // which will result assertion failure
zgu@5272 734 thr = ThreadLocalStorage::thread();
zgu@5272 735 }
zgu@5272 736
zgu@5272 737 if (thr != NULL) {
zgu@5272 738 // Check NMT load
zgu@5272 739 MemTracker::check_NMT_load(thr);
zgu@5272 740
zgu@5272 741 if (thr->is_Java_thread() && ((JavaThread*)thr)->is_safepoint_visible()) {
zgu@5272 742 _java_thread = (JavaThread*)thr;
zgu@5272 743 JavaThreadState state = _java_thread->thread_state();
zgu@5272 744 // JavaThreads that are safepoint safe, can run through safepoint,
zgu@5272 745 // so ThreadCritical is needed to ensure no threads at safepoint create
zgu@5272 746 // new records while the records are being gathered and the sequence number is changing
zgu@5272 747 _need_thread_critical_lock =
zgu@5272 748 SafepointSynchronize::safepoint_safe(_java_thread, state);
zgu@5272 749 } else {
zgu@5272 750 _need_thread_critical_lock = true;
zgu@5272 751 }
zgu@5272 752 } else {
zgu@5272 753 _need_thread_critical_lock
zgu@5272 754 = !MemTracker::is_single_threaded_bootstrap();
zgu@5272 755 }
zgu@5272 756
zgu@5272 757 // see if we need to pre-reserve sequence number for this operation
zgu@5272 758 if (_op == Realloc || _op == Uncommit || _op == Release) {
zgu@5272 759 if (_need_thread_critical_lock) {
zgu@5272 760 ThreadCritical tc;
zgu@5272 761 MemTracker::inc_pending_op_count();
zgu@5272 762 _seq = SequenceGenerator::next();
zgu@5272 763 } else {
zgu@5272 764 // for the threads that honor safepoints, no safepoint can occur
zgu@5272 765 // during the lifespan of tracker, so we don't need to increase
zgu@5272 766 // pending op count.
zgu@5272 767 _seq = SequenceGenerator::next();
zgu@5272 768 }
zgu@5272 769 }
zgu@5272 770 }
zgu@5272 771 }
zgu@5272 772
zgu@5272 773 void MemTracker::Tracker::discard() {
zgu@5272 774 if (MemTracker::is_on() && _seq != 0) {
zgu@5272 775 if (_need_thread_critical_lock) {
zgu@5272 776 ThreadCritical tc;
zgu@5272 777 MemTracker::dec_pending_op_count();
zgu@5272 778 }
zgu@5272 779 _seq = 0;
zgu@5272 780 }
zgu@5272 781 }
zgu@5272 782
zgu@5272 783
zgu@5272 784 void MemTracker::Tracker::record(address old_addr, address new_addr, size_t size,
zgu@5272 785 MEMFLAGS flags, address pc) {
zgu@5272 786 assert(old_addr != NULL && new_addr != NULL, "Sanity check");
zgu@5272 787 assert(_op == Realloc || _op == NoOp, "Wrong call");
zgu@5272 788 if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp) {
zgu@5272 789 assert(_seq > 0, "Need pre-reserve sequence number");
zgu@5272 790 if (_need_thread_critical_lock) {
zgu@5272 791 ThreadCritical tc;
zgu@5272 792 // free old address, use pre-reserved sequence number
zgu@5272 793 MemTracker::write_tracking_record(old_addr, MemPointerRecord::free_tag(),
zgu@5272 794 0, _seq, pc, _java_thread);
zgu@5272 795 MemTracker::write_tracking_record(new_addr, flags | MemPointerRecord::malloc_tag(),
zgu@5272 796 size, SequenceGenerator::next(), pc, _java_thread);
zgu@5272 797 // decrement MemTracker pending_op_count
zgu@5272 798 MemTracker::dec_pending_op_count();
zgu@5272 799 } else {
zgu@5272 800 // free old address, use pre-reserved sequence number
zgu@5272 801 MemTracker::write_tracking_record(old_addr, MemPointerRecord::free_tag(),
zgu@5272 802 0, _seq, pc, _java_thread);
zgu@5272 803 MemTracker::write_tracking_record(new_addr, flags | MemPointerRecord::malloc_tag(),
zgu@5272 804 size, SequenceGenerator::next(), pc, _java_thread);
zgu@5272 805 }
zgu@5272 806 _seq = 0;
zgu@5272 807 }
zgu@5272 808 }
zgu@5272 809
zgu@5272 810 void MemTracker::Tracker::record(address addr, size_t size, MEMFLAGS flags, address pc) {
zgu@5272 811 // OOM already?
zgu@5272 812 if (addr == NULL) return;
zgu@5272 813
zgu@5272 814 if (MemTracker::is_on() && NMT_CAN_TRACK(flags) && _op != NoOp) {
zgu@5272 815 bool pre_reserved_seq = (_seq != 0);
zgu@5272 816 address pc = CALLER_CALLER_PC;
zgu@5272 817 MEMFLAGS orig_flags = flags;
zgu@5272 818
zgu@5272 819 // or the tagging flags
zgu@5272 820 switch(_op) {
zgu@5272 821 case Malloc:
zgu@5272 822 flags |= MemPointerRecord::malloc_tag();
zgu@5272 823 break;
zgu@5272 824 case Free:
zgu@5272 825 flags = MemPointerRecord::free_tag();
zgu@5272 826 break;
zgu@5272 827 case Realloc:
zgu@5272 828 fatal("Use the other Tracker::record()");
zgu@5272 829 break;
zgu@5272 830 case Reserve:
zgu@5272 831 case ReserveAndCommit:
zgu@5272 832 flags |= MemPointerRecord::virtual_memory_reserve_tag();
zgu@5272 833 break;
zgu@5272 834 case Commit:
zgu@5272 835 flags = MemPointerRecord::virtual_memory_commit_tag();
zgu@5272 836 break;
zgu@5272 837 case Type:
zgu@5272 838 flags |= MemPointerRecord::virtual_memory_type_tag();
zgu@5272 839 break;
zgu@5272 840 case Uncommit:
zgu@5272 841 assert(pre_reserved_seq, "Need pre-reserve sequence number");
zgu@5272 842 flags = MemPointerRecord::virtual_memory_uncommit_tag();
zgu@5272 843 break;
zgu@5272 844 case Release:
zgu@5272 845 assert(pre_reserved_seq, "Need pre-reserve sequence number");
zgu@5272 846 flags = MemPointerRecord::virtual_memory_release_tag();
zgu@5272 847 break;
zgu@5272 848 case ArenaSize:
zgu@5272 849 // a bit of hack here, add a small postive offset to arena
zgu@5272 850 // address for its size record, so the size record is sorted
zgu@5272 851 // right after arena record.
zgu@5272 852 flags = MemPointerRecord::arena_size_tag();
zgu@5272 853 addr += sizeof(void*);
zgu@5272 854 break;
zgu@5272 855 case StackRelease:
zgu@5272 856 flags = MemPointerRecord::virtual_memory_release_tag();
zgu@5272 857 break;
zgu@5272 858 default:
zgu@5272 859 ShouldNotReachHere();
zgu@5272 860 }
zgu@5272 861
zgu@5272 862 // write memory tracking record
zgu@5272 863 if (_need_thread_critical_lock) {
zgu@5272 864 ThreadCritical tc;
zgu@5272 865 if (_seq == 0) _seq = SequenceGenerator::next();
zgu@5272 866 MemTracker::write_tracking_record(addr, flags, size, _seq, pc, _java_thread);
zgu@5272 867 if (_op == ReserveAndCommit) {
zgu@5272 868 MemTracker::write_tracking_record(addr, orig_flags | MemPointerRecord::virtual_memory_commit_tag(),
zgu@5272 869 size, SequenceGenerator::next(), pc, _java_thread);
zgu@5272 870 }
zgu@5272 871 if (pre_reserved_seq) MemTracker::dec_pending_op_count();
zgu@5272 872 } else {
zgu@5272 873 if (_seq == 0) _seq = SequenceGenerator::next();
zgu@5272 874 MemTracker::write_tracking_record(addr, flags, size, _seq, pc, _java_thread);
zgu@5272 875 if (_op == ReserveAndCommit) {
zgu@5272 876 MemTracker::write_tracking_record(addr, orig_flags | MemPointerRecord::virtual_memory_commit_tag(),
zgu@5272 877 size, SequenceGenerator::next(), pc, _java_thread);
zgu@5272 878 }
zgu@5272 879 }
zgu@5272 880 _seq = 0;
zgu@5272 881 }
zgu@5272 882 }
zgu@5272 883

mercurial