mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
Merge
This commit is contained in:
commit
02472faab5
10 changed files with 139 additions and 39 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -35,16 +35,16 @@ import sun.jvm.hotspot.tools.*;
|
||||||
import sun.jvm.hotspot.utilities.*;
|
import sun.jvm.hotspot.utilities.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A command line tool to print perm. generation statistics.
|
A command line tool to print class loader statistics.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class PermStat extends Tool {
|
public class ClassLoaderStats extends Tool {
|
||||||
boolean verbose = true;
|
boolean verbose = true;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
PermStat ps = new PermStat();
|
ClassLoaderStats cls = new ClassLoaderStats();
|
||||||
ps.start(args);
|
cls.start(args);
|
||||||
ps.stop();
|
cls.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ClassData {
|
private static class ClassData {
|
|
@ -57,17 +57,18 @@ public class HeapSummary extends Tool {
|
||||||
printGCAlgorithm(flagMap);
|
printGCAlgorithm(flagMap);
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("Heap Configuration:");
|
System.out.println("Heap Configuration:");
|
||||||
printValue("MinHeapFreeRatio = ", getFlagValue("MinHeapFreeRatio", flagMap));
|
printValue("MinHeapFreeRatio = ", getFlagValue("MinHeapFreeRatio", flagMap));
|
||||||
printValue("MaxHeapFreeRatio = ", getFlagValue("MaxHeapFreeRatio", flagMap));
|
printValue("MaxHeapFreeRatio = ", getFlagValue("MaxHeapFreeRatio", flagMap));
|
||||||
printValMB("MaxHeapSize = ", getFlagValue("MaxHeapSize", flagMap));
|
printValMB("MaxHeapSize = ", getFlagValue("MaxHeapSize", flagMap));
|
||||||
printValMB("NewSize = ", getFlagValue("NewSize", flagMap));
|
printValMB("NewSize = ", getFlagValue("NewSize", flagMap));
|
||||||
printValMB("MaxNewSize = ", getFlagValue("MaxNewSize", flagMap));
|
printValMB("MaxNewSize = ", getFlagValue("MaxNewSize", flagMap));
|
||||||
printValMB("OldSize = ", getFlagValue("OldSize", flagMap));
|
printValMB("OldSize = ", getFlagValue("OldSize", flagMap));
|
||||||
printValue("NewRatio = ", getFlagValue("NewRatio", flagMap));
|
printValue("NewRatio = ", getFlagValue("NewRatio", flagMap));
|
||||||
printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap));
|
printValue("SurvivorRatio = ", getFlagValue("SurvivorRatio", flagMap));
|
||||||
printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap));
|
printValMB("MetaspaceSize = ", getFlagValue("MetaspaceSize", flagMap));
|
||||||
printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap));
|
printValMB("ClassMetaspaceSize = ", getFlagValue("ClassMetaspaceSize", flagMap));
|
||||||
printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes());
|
printValMB("MaxMetaspaceSize = ", getFlagValue("MaxMetaspaceSize", flagMap));
|
||||||
|
printValMB("G1HeapRegionSize = ", HeapRegion.grainBytes());
|
||||||
|
|
||||||
System.out.println();
|
System.out.println();
|
||||||
System.out.println("Heap Usage:");
|
System.out.println("Heap Usage:");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -45,7 +45,7 @@ public class JMap extends Tool {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getCommandFlags() {
|
protected String getCommandFlags() {
|
||||||
return "-heap|-heap:format=b|-histo|-permstat|-finalizerinfo";
|
return "-heap|-heap:format=b|-histo|-clstats|-finalizerinfo";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void printFlagsUsage() {
|
protected void printFlagsUsage() {
|
||||||
|
@ -53,14 +53,14 @@ public class JMap extends Tool {
|
||||||
System.out.println(" -heap\tto print java heap summary");
|
System.out.println(" -heap\tto print java heap summary");
|
||||||
System.out.println(" -heap:format=b\tto dump java heap in hprof binary format");
|
System.out.println(" -heap:format=b\tto dump java heap in hprof binary format");
|
||||||
System.out.println(" -histo\tto print histogram of java object heap");
|
System.out.println(" -histo\tto print histogram of java object heap");
|
||||||
System.out.println(" -permstat\tto print permanent generation statistics");
|
System.out.println(" -clstats\tto print class loader statistics");
|
||||||
System.out.println(" -finalizerinfo\tto print information on objects awaiting finalization");
|
System.out.println(" -finalizerinfo\tto print information on objects awaiting finalization");
|
||||||
super.printFlagsUsage();
|
super.printFlagsUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final int MODE_HEAP_SUMMARY = 0;
|
public static final int MODE_HEAP_SUMMARY = 0;
|
||||||
public static final int MODE_HISTOGRAM = 1;
|
public static final int MODE_HISTOGRAM = 1;
|
||||||
public static final int MODE_PERMSTAT = 2;
|
public static final int MODE_CLSTATS = 2;
|
||||||
public static final int MODE_PMAP = 3;
|
public static final int MODE_PMAP = 3;
|
||||||
public static final int MODE_HEAP_GRAPH_HPROF_BIN = 4;
|
public static final int MODE_HEAP_GRAPH_HPROF_BIN = 4;
|
||||||
public static final int MODE_HEAP_GRAPH_GXL = 5;
|
public static final int MODE_HEAP_GRAPH_GXL = 5;
|
||||||
|
@ -78,8 +78,8 @@ public class JMap extends Tool {
|
||||||
tool = new ObjectHistogram();
|
tool = new ObjectHistogram();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_PERMSTAT:
|
case MODE_CLSTATS:
|
||||||
tool = new PermStat();
|
tool = new ClassLoaderStats();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_PMAP:
|
case MODE_PMAP:
|
||||||
|
@ -118,7 +118,9 @@ public class JMap extends Tool {
|
||||||
} else if (modeFlag.equals("-histo")) {
|
} else if (modeFlag.equals("-histo")) {
|
||||||
mode = MODE_HISTOGRAM;
|
mode = MODE_HISTOGRAM;
|
||||||
} else if (modeFlag.equals("-permstat")) {
|
} else if (modeFlag.equals("-permstat")) {
|
||||||
mode = MODE_PERMSTAT;
|
mode = MODE_CLSTATS;
|
||||||
|
} else if (modeFlag.equals("-clstats")) {
|
||||||
|
mode = MODE_CLSTATS;
|
||||||
} else if (modeFlag.equals("-finalizerinfo")) {
|
} else if (modeFlag.equals("-finalizerinfo")) {
|
||||||
mode = MODE_FINALIZERINFO;
|
mode = MODE_FINALIZERINFO;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -117,7 +117,7 @@ void ConcurrentMarkThread::run() {
|
||||||
if (G1Log::fine()) {
|
if (G1Log::fine()) {
|
||||||
gclog_or_tty->date_stamp(PrintGCDateStamps);
|
gclog_or_tty->date_stamp(PrintGCDateStamps);
|
||||||
gclog_or_tty->stamp(PrintGCTimeStamps);
|
gclog_or_tty->stamp(PrintGCTimeStamps);
|
||||||
gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf]",
|
gclog_or_tty->print_cr("[GC concurrent-root-region-scan-end, %1.7lf secs]",
|
||||||
scan_end - scan_start);
|
scan_end - scan_start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ void ConcurrentMarkThread::run() {
|
||||||
if (G1Log::fine()) {
|
if (G1Log::fine()) {
|
||||||
gclog_or_tty->date_stamp(PrintGCDateStamps);
|
gclog_or_tty->date_stamp(PrintGCDateStamps);
|
||||||
gclog_or_tty->stamp(PrintGCTimeStamps);
|
gclog_or_tty->stamp(PrintGCTimeStamps);
|
||||||
gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf sec]",
|
gclog_or_tty->print_cr("[GC concurrent-mark-end, %1.7lf secs]",
|
||||||
mark_end_sec - mark_start_sec);
|
mark_end_sec - mark_start_sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ void ConcurrentMarkThread::run() {
|
||||||
if (G1Log::fine()) {
|
if (G1Log::fine()) {
|
||||||
gclog_or_tty->date_stamp(PrintGCDateStamps);
|
gclog_or_tty->date_stamp(PrintGCDateStamps);
|
||||||
gclog_or_tty->stamp(PrintGCTimeStamps);
|
gclog_or_tty->stamp(PrintGCTimeStamps);
|
||||||
gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf]",
|
gclog_or_tty->print_cr("[GC concurrent-cleanup-end, %1.7lf secs]",
|
||||||
cleanup_end_sec - cleanup_start_sec);
|
cleanup_end_sec - cleanup_start_sec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,15 @@ G1CollectorPolicy::G1CollectorPolicy() :
|
||||||
double max_gc_time = (double) MaxGCPauseMillis / 1000.0;
|
double max_gc_time = (double) MaxGCPauseMillis / 1000.0;
|
||||||
double time_slice = (double) GCPauseIntervalMillis / 1000.0;
|
double time_slice = (double) GCPauseIntervalMillis / 1000.0;
|
||||||
_mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
|
_mmu_tracker = new G1MMUTrackerQueue(time_slice, max_gc_time);
|
||||||
_sigma = (double) G1ConfidencePercent / 100.0;
|
|
||||||
|
uintx confidence_perc = G1ConfidencePercent;
|
||||||
|
// Put an artificial ceiling on this so that it's not set to a silly value.
|
||||||
|
if (confidence_perc > 100) {
|
||||||
|
confidence_perc = 100;
|
||||||
|
warning("G1ConfidencePercent is set to a value that is too large, "
|
||||||
|
"it's been updated to %u", confidence_perc);
|
||||||
|
}
|
||||||
|
_sigma = (double) confidence_perc / 100.0;
|
||||||
|
|
||||||
// start conservatively (around 50ms is about right)
|
// start conservatively (around 50ms is about right)
|
||||||
_concurrent_mark_remark_times_ms->add(0.05);
|
_concurrent_mark_remark_times_ms->add(0.05);
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
|
|
||||||
#define G1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw) \
|
#define G1_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw) \
|
||||||
\
|
\
|
||||||
product(intx, G1ConfidencePercent, 50, \
|
product(uintx, G1ConfidencePercent, 50, \
|
||||||
"Confidence level for MMU/pause predictions") \
|
"Confidence level for MMU/pause predictions") \
|
||||||
\
|
\
|
||||||
develop(intx, G1MarkingOverheadPercent, 0, \
|
develop(intx, G1MarkingOverheadPercent, 0, \
|
||||||
|
|
|
@ -29,10 +29,17 @@
|
||||||
|
|
||||||
class Atomic : AllStatic {
|
class Atomic : AllStatic {
|
||||||
public:
|
public:
|
||||||
|
// Atomic operations on jlong types are not available on all 32-bit
|
||||||
|
// platforms. If atomic ops on jlongs are defined here they must only
|
||||||
|
// be used from code that verifies they are available at runtime and
|
||||||
|
// can provide an alternative action if not - see supports_cx8() for
|
||||||
|
// a means to test availability.
|
||||||
|
|
||||||
// Atomically store to a location
|
// Atomically store to a location
|
||||||
inline static void store (jbyte store_value, jbyte* dest);
|
inline static void store (jbyte store_value, jbyte* dest);
|
||||||
inline static void store (jshort store_value, jshort* dest);
|
inline static void store (jshort store_value, jshort* dest);
|
||||||
inline static void store (jint store_value, jint* dest);
|
inline static void store (jint store_value, jint* dest);
|
||||||
|
// See comment above about using jlong atomics on 32-bit platforms
|
||||||
inline static void store (jlong store_value, jlong* dest);
|
inline static void store (jlong store_value, jlong* dest);
|
||||||
inline static void store_ptr(intptr_t store_value, intptr_t* dest);
|
inline static void store_ptr(intptr_t store_value, intptr_t* dest);
|
||||||
inline static void store_ptr(void* store_value, void* dest);
|
inline static void store_ptr(void* store_value, void* dest);
|
||||||
|
@ -40,17 +47,19 @@ class Atomic : AllStatic {
|
||||||
inline static void store (jbyte store_value, volatile jbyte* dest);
|
inline static void store (jbyte store_value, volatile jbyte* dest);
|
||||||
inline static void store (jshort store_value, volatile jshort* dest);
|
inline static void store (jshort store_value, volatile jshort* dest);
|
||||||
inline static void store (jint store_value, volatile jint* dest);
|
inline static void store (jint store_value, volatile jint* dest);
|
||||||
|
// See comment above about using jlong atomics on 32-bit platforms
|
||||||
inline static void store (jlong store_value, volatile jlong* dest);
|
inline static void store (jlong store_value, volatile jlong* dest);
|
||||||
inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest);
|
inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest);
|
||||||
inline static void store_ptr(void* store_value, volatile void* dest);
|
inline static void store_ptr(void* store_value, volatile void* dest);
|
||||||
|
|
||||||
|
// See comment above about using jlong atomics on 32-bit platforms
|
||||||
inline static jlong load(volatile jlong* src);
|
inline static jlong load(volatile jlong* src);
|
||||||
|
|
||||||
// Atomically add to a location, return updated value
|
// Atomically add to a location, return updated value
|
||||||
inline static jint add (jint add_value, volatile jint* dest);
|
inline static jint add (jint add_value, volatile jint* dest);
|
||||||
inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest);
|
inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest);
|
||||||
inline static void* add_ptr(intptr_t add_value, volatile void* dest);
|
inline static void* add_ptr(intptr_t add_value, volatile void* dest);
|
||||||
|
// See comment above about using jlong atomics on 32-bit platforms
|
||||||
static jlong add (jlong add_value, volatile jlong* dest);
|
static jlong add (jlong add_value, volatile jlong* dest);
|
||||||
|
|
||||||
// Atomically increment location
|
// Atomically increment location
|
||||||
|
@ -75,6 +84,7 @@ class Atomic : AllStatic {
|
||||||
// barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'.
|
// barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'.
|
||||||
static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value);
|
static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value);
|
||||||
inline static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value);
|
inline static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value);
|
||||||
|
// See comment above about using jlong atomics on 32-bit platforms
|
||||||
inline static jlong cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value);
|
inline static jlong cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value);
|
||||||
|
|
||||||
static unsigned int cmpxchg(unsigned int exchange_value,
|
static unsigned int cmpxchg(unsigned int exchange_value,
|
||||||
|
|
|
@ -431,7 +431,7 @@ rotatingFileStream::~rotatingFileStream() {
|
||||||
|
|
||||||
rotatingFileStream::rotatingFileStream(const char* file_name) {
|
rotatingFileStream::rotatingFileStream(const char* file_name) {
|
||||||
_cur_file_num = 0;
|
_cur_file_num = 0;
|
||||||
_bytes_writen = 0L;
|
_bytes_written = 0L;
|
||||||
_file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal);
|
_file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal);
|
||||||
jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num);
|
jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num);
|
||||||
_file = fopen(_file_name, "w");
|
_file = fopen(_file_name, "w");
|
||||||
|
@ -440,7 +440,7 @@ rotatingFileStream::rotatingFileStream(const char* file_name) {
|
||||||
|
|
||||||
rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) {
|
rotatingFileStream::rotatingFileStream(const char* file_name, const char* opentype) {
|
||||||
_cur_file_num = 0;
|
_cur_file_num = 0;
|
||||||
_bytes_writen = 0L;
|
_bytes_written = 0L;
|
||||||
_file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal);
|
_file_name = NEW_C_HEAP_ARRAY(char, strlen(file_name)+10, mtInternal);
|
||||||
jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num);
|
jio_snprintf(_file_name, strlen(file_name)+10, "%s.%d", file_name, _cur_file_num);
|
||||||
_file = fopen(_file_name, opentype);
|
_file = fopen(_file_name, opentype);
|
||||||
|
@ -448,10 +448,9 @@ rotatingFileStream::rotatingFileStream(const char* file_name, const char* openty
|
||||||
}
|
}
|
||||||
|
|
||||||
void rotatingFileStream::write(const char* s, size_t len) {
|
void rotatingFileStream::write(const char* s, size_t len) {
|
||||||
if (_file != NULL) {
|
if (_file != NULL) {
|
||||||
// Make an unused local variable to avoid warning from gcc 4.x compiler.
|
|
||||||
size_t count = fwrite(s, 1, len, _file);
|
size_t count = fwrite(s, 1, len, _file);
|
||||||
Atomic::add((jlong)count, &_bytes_writen);
|
_bytes_written += count;
|
||||||
}
|
}
|
||||||
update_position(s, len);
|
update_position(s, len);
|
||||||
}
|
}
|
||||||
|
@ -465,7 +464,10 @@ void rotatingFileStream::write(const char* s, size_t len) {
|
||||||
// concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log
|
// concurrent GC threads to run parallel with VMThread at safepoint, write and rotate_log
|
||||||
// must be synchronized.
|
// must be synchronized.
|
||||||
void rotatingFileStream::rotate_log() {
|
void rotatingFileStream::rotate_log() {
|
||||||
if (_bytes_writen < (jlong)GCLogFileSize) return;
|
if (_bytes_written < (jlong)GCLogFileSize) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ASSERT
|
#ifdef ASSERT
|
||||||
Thread *thread = Thread::current();
|
Thread *thread = Thread::current();
|
||||||
assert(thread == NULL ||
|
assert(thread == NULL ||
|
||||||
|
@ -475,7 +477,7 @@ void rotatingFileStream::rotate_log() {
|
||||||
if (NumberOfGCLogFiles == 1) {
|
if (NumberOfGCLogFiles == 1) {
|
||||||
// rotate in same file
|
// rotate in same file
|
||||||
rewind();
|
rewind();
|
||||||
_bytes_writen = 0L;
|
_bytes_written = 0L;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +493,7 @@ void rotatingFileStream::rotate_log() {
|
||||||
}
|
}
|
||||||
_file = fopen(_file_name, "w");
|
_file = fopen(_file_name, "w");
|
||||||
if (_file != NULL) {
|
if (_file != NULL) {
|
||||||
_bytes_writen = 0L;
|
_bytes_written = 0L;
|
||||||
_need_close = true;
|
_need_close = true;
|
||||||
} else {
|
} else {
|
||||||
tty->print_cr("failed to open rotation log file %s due to %s\n",
|
tty->print_cr("failed to open rotation log file %s due to %s\n",
|
||||||
|
|
|
@ -231,7 +231,7 @@ class fdStream : public outputStream {
|
||||||
class rotatingFileStream : public fileStream {
|
class rotatingFileStream : public fileStream {
|
||||||
protected:
|
protected:
|
||||||
char* _file_name;
|
char* _file_name;
|
||||||
jlong _bytes_writen;
|
jlong _bytes_written;
|
||||||
uintx _cur_file_num; // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1
|
uintx _cur_file_num; // current logfile rotation number, from 0 to MaxGCLogFileNumbers-1
|
||||||
public:
|
public:
|
||||||
rotatingFileStream(const char* file_name);
|
rotatingFileStream(const char* file_name);
|
||||||
|
|
77
hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java
Normal file
77
hotspot/test/gc/metaspace/ClassMetaspaceSizeInJmapHeap.java
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2013, 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test ClassMetaspaceSizeInJmapHeap
|
||||||
|
* @bug 8004924
|
||||||
|
* @summary Checks that jmap -heap contains the flag ClassMetaspaceSize
|
||||||
|
* @library /testlibrary
|
||||||
|
* @run main/othervm -XX:ClassMetaspaceSize=50m ClassMetaspaceSizeInJmapHeap
|
||||||
|
*/
|
||||||
|
|
||||||
|
import com.oracle.java.testlibrary.*;
|
||||||
|
import java.nio.file.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ClassMetaspaceSizeInJmapHeap {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
String pid = Integer.toString(ProcessTools.getProcessId());
|
||||||
|
|
||||||
|
ProcessBuilder pb = new ProcessBuilder();
|
||||||
|
pb.command(JDKToolFinder.getJDKTool("jmap"), "-heap", pid);
|
||||||
|
|
||||||
|
File out = new File("ClassMetaspaceSizeInJmapHeap.stdout.txt");
|
||||||
|
pb.redirectOutput(out);
|
||||||
|
|
||||||
|
File err = new File("ClassMetaspaceSizeInJmapHeap.stderr.txt");
|
||||||
|
pb.redirectError(err);
|
||||||
|
|
||||||
|
run(pb);
|
||||||
|
|
||||||
|
OutputAnalyzer output = new OutputAnalyzer(read(out));
|
||||||
|
output.shouldContain("ClassMetaspaceSize = 52428800 (50.0MB)");
|
||||||
|
out.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void run(ProcessBuilder pb) throws Exception {
|
||||||
|
Process p = pb.start();
|
||||||
|
p.waitFor();
|
||||||
|
int exitValue = p.exitValue();
|
||||||
|
if (exitValue != 0) {
|
||||||
|
throw new Exception("jmap -heap exited with error code: " + exitValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String read(File f) throws Exception {
|
||||||
|
Path p = f.toPath();
|
||||||
|
List<String> lines = Files.readAllLines(p, Charset.defaultCharset());
|
||||||
|
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String line : lines) {
|
||||||
|
sb.append(line).append('\n');
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue