memTracker.hpp revision 4311
4168N/A * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. 3863N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3863N/A * This code is free software; you can redistribute it and/or modify it 3863N/A * under the terms of the GNU General Public License version 2 only, as 3863N/A * published by the Free Software Foundation. 3863N/A * This code is distributed in the hope that it will be useful, but WITHOUT 3863N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 3863N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 3863N/A * version 2 for more details (a copy is included in the LICENSE file that 3863N/A * You should have received a copy of the GNU General Public License version 3863N/A * 2 along with this work; if not, write to the Free Software Foundation, 3863N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 3863N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 3863N/A// The thread closure walks threads to collect per-thread 3863N/A// memory recorders at NMT sync point 3863N/A * MemTracker is the 'gate' class to native memory tracking runtime. 3863N/A // native memory tracking level 3863N/A // initialize NMT tracking level from command line options, called 3863N/A // from VM command line parsing code 3863N/A // if NMT is enabled to record memory activities 3863N/A // user readable reason for shutting down NMT 3863N/A return "Native memory tracking is not enabled";
3863N/A return "Native memory tracking has been shutdown by user";
3863N/A return "Native memory tracking has been shutdown due to process exiting";
3898N/A return "Native memory tracking has been shutdown due to out of native memory";
3863N/A return "Native memory tracking failed to initialize";
3863N/A return "Native memory tracking has been shutdown due to error reporting";
3863N/A return "Native memory tracking has been shutdown due to running out of generation buffer";
3863N/A return "Native memory tracking has been shutdown due to overflow the sequence number";
3863N/A return "Native memory tracking is not supported when UseMallocOnly is on";
3863N/A // test if we can walk native stack 3863N/A // native stack is not walkable during bootstrapping on sparc 3863N/A // if native memory tracking tracks callsite 4311N/A // NMT automatically shuts itself down under extreme situation by default. 4311N/A // When the value is set to false, NMT will try its best to stay alive, 4311N/A // even it has to slow down VM. 3863N/A // shutdown native memory tracking capability. Native memory tracking 3863N/A // can be shutdown by VM when it encounters low memory scenarios. 3863N/A // Memory tracker should gracefully shutdown itself, and preserve the 3863N/A // latest memory statistics for post morten diagnosis. 3863N/A // if there is shutdown requested 3863N/A // bootstrap native memory tracking, so it can start to collect raw data 3863N/A // before worker thread can start 3863N/A // the first phase of bootstrapping, when VM still in single-threaded mode 3863N/A // the second phase of bootstrapping, VM is about or already in multi-threaded mode 3863N/A // start() has to be called when VM still in single thread mode, but after 3863N/A // command line option parsing is done. 4066N/A // record arena memory size 4066N/A // we add a positive offset to arena address, so we can have arena memory record 3863N/A // sorted after arena record 3863N/A // record a virtual memory 'reserve' call 3863N/A // record a virtual memory 'commit' call 3863N/A // record a virtual memory 'uncommit' call 3863N/A // record a virtual memory 'release' call 3863N/A // record memory type on virtual memory base address 3863N/A // create memory baseline of current memory snapshot 3863N/A // is there a memory baseline 3863N/A // print memory usage from current snapshot 3863N/A // compare memory usage between current snapshot and baseline 4186N/A // the version for whitebox testing support, it ensures that all memory 4186N/A // activities before this method call, are reflected in the snapshot 3863N/A // sync is called within global safepoint to synchronize nmt data 3863N/A // called when a thread is about to exit 3863N/A // retrieve global snapshot 3863N/A // start native memory tracking worker thread 3863N/A // called by worker thread to complete shutdown process 3863N/A // retrieve per-thread recorder of the specified thread. 3863N/A // if the recorder is full, it will be enqueued to overflow 3863N/A // queue, a new recorder is acquired from recorder pool or a 3863N/A // new instance is created. 3863N/A // when thread == NULL, it means global recorder 3863N/A // per-thread recorder pool 3863N/A // pending recorder queue. Recorders are queued to pending queue 3863N/A // when they are overflowed or collected at nmt sync point. 3863N/A // retrieve a pooled memory record or create new one if there is not 3863N/A // a memory baseline of snapshot 3863N/A // a thread can start to allocate memory before it is attached 3863N/A // to VM 'Thread', those memory activities are recorded here. 3863N/A // ThreadCritical is required to guard this global recorder. 3863N/A // pending recorders to be merged 3863N/A // memory recorder pool management, uses following 3863N/A // counter to determine if a released memory recorder 3863N/A // worker thread to merge pending recorders into snapshot 3863N/A // how many safepoints we skipped without entering sync point 3863N/A // if the tracker is properly intialized 3863N/A // tracking level (off, summary and detail) 3863N/A // the reason for shutting down nmt 4186N/A // the generation that NMT is processing 4186N/A // although NMT is still procesing current generation, but 4186N/A // there is not more recorder to process, set idle state 4311N/A // if NMT should slow down calling thread to allow 4311N/A // worker thread to catch up 3863N/A#
endif // SHARE_VM_SERVICES_MEM_TRACKER_HPP