/* * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Prefix of performance data file. constchar PERFDATA_NAME[] = "hsperfdata";
// Add 1 for the '_' character between PERFDATA_NAME and pid. The '\0' terminating // character will be included in the sizeof(PERFDATA_NAME) operation. staticconst size_t PERFDATA_FILENAME_LEN = sizeof(PERFDATA_NAME) +
UINT_CHARS + 1;
if (!UsePerfData) return; if (!PerfMemory::is_usable()) return;
// Only destroy PerfData objects if we're at a safepoint and the // StatSampler is not active. Otherwise, we risk removing PerfData // objects that are currently being used by running JavaThreads // or the StatSampler. This method is invoked while we are not at // a safepoint during a VM abort so leaving the PerfData objects // around may also help diagnose the failure. In rare cases, // PerfData objects are used in parallel with a safepoint. See // the work around in PerfDataManager::destroy(). // if (SafepointSynchronize::is_at_safepoint() && !StatSampler::is_active()) {
PerfDataManager::destroy();
}
// Remove the persistent external resources, if any. This method // does not unmap or invalidate any virtual memory allocated during // initialization. //
PerfMemory::destroy();
}
void PerfMemory::initialize() {
if (is_initialized()) // initialization already performed return;
// allocate PerfData memory region
create_memory_region(capacity);
if (_start == NULL) {
// the PerfMemory region could not be created as desired. Rather // than terminating the JVM, we revert to creating the instrumentation // on the C heap. When running in this mode, external monitoring // clients cannot attach to and monitor this JVM. // // the warning is issued only in debug mode in order to avoid // additional output to the stdout or stderr output streams. // if (PrintMiscellaneous && Verbose) {
warning("Could not create PerfData Memory region, reverting to malloc");
}
// This state indicates that the contiguous memory region exists and // that it wasn't large enough to hold all the counters. In this case, // we output a warning message to the user on exit if the -XX:+Verbose // flag is set (a debug only flag). External monitoring tools can detect // this condition by monitoring the _prologue->overflow word. // // There are two tunables that can help resolve this issue: // - increase the size of the PerfMemory with -XX:PerfDataMemorySize=<n> // - decrease the maximum string constant length with // -XX:PerfMaxStringConstLength=<n> // if (PrintMiscellaneous && Verbose) {
warning("PerfMemory Overflow Occurred.\n" "\tCapacity = " SIZE_FORMAT " bytes" " Used = " SIZE_FORMAT " bytes" " Overflow = " INT32_FORMAT " bytes" "\n\tUse -XX:PerfDataMemorySize= to specify larger size.",
PerfMemory::capacity(),
PerfMemory::used(),
_prologue->overflow);
}
}
if (_start != NULL) {
// this state indicates that the contiguous memory region was successfully // and that persistent resources may need to be cleaned up. This is // expected to be the typical condition. //
delete_memory_region();
}
_destroyed = true;
}
// allocate an aligned block of memory from the PerfData memory // region. This method assumes that the PerfData memory region // was aligned on a double word boundary when created. // char* PerfMemory::alloc(size_t size) {
if (!UsePerfData) return NULL;
MutexLocker ml(PerfDataMemAlloc_lock);
assert(is_usable(), "called before init or after destroy");
// check that there is enough memory for this request if ((_top + size) >= _end) {
_prologue->overflow += (jint)size;
return NULL;
}
char* result = _top;
_top += size;
assert(contains(result), "PerfData memory pointer out of range");
// Returns the complete path including the file name of performance data file. // Caller is expected to release the allocated memory. char* PerfMemory::get_perfdata_file_path() { char* dest_file = NULL;
if (PerfDataSaveFile != NULL) { // dest_file_name stores the validated file name if file_name // contains %p which will be replaced by pid.
dest_file = NEW_C_HEAP_ARRAY(char, JVM_MAXPATHLEN, mtInternal); if(!Arguments::copy_expand_pid(PerfDataSaveFile, strlen(PerfDataSaveFile),
dest_file, JVM_MAXPATHLEN)) {
FREE_C_HEAP_ARRAY(char, dest_file); if (PrintMiscellaneous && Verbose) {
warning("Invalid performance data file path name specified, "\ "fall back to a default name");
}
} else { return dest_file;
}
} // create the name of the file for retaining the instrumentation memory.
dest_file = NEW_C_HEAP_ARRAY(char, PERFDATA_FILENAME_LEN, mtInternal);
jio_snprintf(dest_file, PERFDATA_FILENAME_LEN, "%s_%d", PERFDATA_NAME, os::current_process_id());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.