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 // create thread uses cgc thread type for now. We should revisit 3863N/A // the option, or create new thread type. 3863N/A // initial generation circuit buffer 3863N/A * Native memory tracking worker thread loop: 3863N/A * 1. merge one generation of memory recorders to staging area 3863N/A * 2. promote staging data to memory snapshot 3863N/A * This thread can run through safepoint. 3863N/A // take a recorder from earliest generation in buffer 3863N/A // merge the recorder into staging area 3863N/A // no more recorder to merge, promote staging area 3863N/A // done with this generation, increment _head pointer 3863N/A // promote this generation data to snapshot 4058N/A // failed to promote, means out of memory 3863N/A // check if more data arrived 3949N/A // transits to final shutdown 3863N/A// at synchronization point, where 'safepoint visible' Java threads are blocked 3863N/A// at a safepoint, and the rest of threads are blocked on ThreadCritical lock. 3863N/A// The caller MemTracker::sync() already takes ThreadCritical before calling this 3863N/A// Following tasks are performed: 3863N/A// 1. add all recorders in pending queue to current generation 3863N/A "pending queue has infinite loop");
3863N/A // check shutdown state inside ThreadCritical 3863N/A // append the recorders to the end of the generation 3863N/A "after add to current generation has infinite loop");
3863N/A // we have collected all recorders for this generation. If there is data, 3863N/A // we need to increment _tail to start a new generation.