mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8061715: gc/g1/TestShrinkAuxiliaryData15.java fails with java.lang.RuntimeException: heap decommit failed - after > before
Added WhiteBox methods to count regions and exact aux data sizes Reviewed-by: tschatzl, jwilhelm, mgerdin
This commit is contained in:
parent
7e86840f64
commit
9272128a46
13 changed files with 192 additions and 75 deletions
|
@ -1118,6 +1118,10 @@ public:
|
||||||
// The number of regions that are completely free.
|
// The number of regions that are completely free.
|
||||||
uint num_free_regions() const { return _hrm.num_free_regions(); }
|
uint num_free_regions() const { return _hrm.num_free_regions(); }
|
||||||
|
|
||||||
|
MemoryUsage get_auxiliary_data_memory_usage() const {
|
||||||
|
return _hrm.get_auxiliary_data_memory_usage();
|
||||||
|
}
|
||||||
|
|
||||||
// The number of regions that are not completely free.
|
// The number of regions that are not completely free.
|
||||||
uint num_used_regions() const { return num_regions() - num_free_regions(); }
|
uint num_used_regions() const { return num_regions() - num_free_regions(); }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -57,6 +57,9 @@ class G1RegionToSpaceMapper : public CHeapObj<mtGC> {
|
||||||
public:
|
public:
|
||||||
MemRegion reserved() { return _storage.reserved(); }
|
MemRegion reserved() { return _storage.reserved(); }
|
||||||
|
|
||||||
|
size_t reserved_size() { return _storage.reserved_size(); }
|
||||||
|
size_t committed_size() { return _storage.committed_size(); }
|
||||||
|
|
||||||
void set_mapping_changed_listener(G1MappingChangedListener* listener) { _listener = listener; }
|
void set_mapping_changed_listener(G1MappingChangedListener* listener) { _listener = listener; }
|
||||||
|
|
||||||
virtual ~G1RegionToSpaceMapper() {
|
virtual ~G1RegionToSpaceMapper() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2015, 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
|
||||||
|
@ -145,6 +145,24 @@ void HeapRegionManager::make_regions_available(uint start, uint num_regions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MemoryUsage HeapRegionManager::get_auxiliary_data_memory_usage() const {
|
||||||
|
size_t used_sz =
|
||||||
|
_prev_bitmap_mapper->committed_size() +
|
||||||
|
_next_bitmap_mapper->committed_size() +
|
||||||
|
_bot_mapper->committed_size() +
|
||||||
|
_cardtable_mapper->committed_size() +
|
||||||
|
_card_counts_mapper->committed_size();
|
||||||
|
|
||||||
|
size_t committed_sz =
|
||||||
|
_prev_bitmap_mapper->reserved_size() +
|
||||||
|
_next_bitmap_mapper->reserved_size() +
|
||||||
|
_bot_mapper->reserved_size() +
|
||||||
|
_cardtable_mapper->reserved_size() +
|
||||||
|
_card_counts_mapper->reserved_size();
|
||||||
|
|
||||||
|
return MemoryUsage(0, used_sz, committed_sz, committed_sz);
|
||||||
|
}
|
||||||
|
|
||||||
uint HeapRegionManager::expand_by(uint num_regions) {
|
uint HeapRegionManager::expand_by(uint num_regions) {
|
||||||
return expand_at(0, num_regions);
|
return expand_at(0, num_regions);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2015, 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
|
||||||
|
@ -28,6 +28,7 @@
|
||||||
#include "gc_implementation/g1/g1BiasedArray.hpp"
|
#include "gc_implementation/g1/g1BiasedArray.hpp"
|
||||||
#include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
|
#include "gc_implementation/g1/g1RegionToSpaceMapper.hpp"
|
||||||
#include "gc_implementation/g1/heapRegionSet.hpp"
|
#include "gc_implementation/g1/heapRegionSet.hpp"
|
||||||
|
#include "services/memoryUsage.hpp"
|
||||||
|
|
||||||
class HeapRegion;
|
class HeapRegion;
|
||||||
class HeapRegionClosure;
|
class HeapRegionClosure;
|
||||||
|
@ -196,6 +197,8 @@ public:
|
||||||
// Return the maximum number of regions in the heap.
|
// Return the maximum number of regions in the heap.
|
||||||
uint max_length() const { return (uint)_regions.length(); }
|
uint max_length() const { return (uint)_regions.length(); }
|
||||||
|
|
||||||
|
MemoryUsage get_auxiliary_data_memory_usage() const;
|
||||||
|
|
||||||
MemRegion reserved() const { return MemRegion(heap_bottom(), heap_end()); }
|
MemRegion reserved() const { return MemRegion(heap_bottom(), heap_end()); }
|
||||||
|
|
||||||
// Expand the sequence to reflect that the heap has grown. Either create new
|
// Expand the sequence to reflect that the heap has grown. Either create new
|
||||||
|
|
|
@ -295,6 +295,12 @@ WB_ENTRY(jboolean, WB_G1IsHumongous(JNIEnv* env, jobject o, jobject obj))
|
||||||
return hr->is_humongous();
|
return hr->is_humongous();
|
||||||
WB_END
|
WB_END
|
||||||
|
|
||||||
|
WB_ENTRY(jlong, WB_G1NumMaxRegions(JNIEnv* env, jobject o))
|
||||||
|
G1CollectedHeap* g1 = G1CollectedHeap::heap();
|
||||||
|
size_t nr = g1->max_regions();
|
||||||
|
return (jlong)nr;
|
||||||
|
WB_END
|
||||||
|
|
||||||
WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
|
WB_ENTRY(jlong, WB_G1NumFreeRegions(JNIEnv* env, jobject o))
|
||||||
G1CollectedHeap* g1 = G1CollectedHeap::heap();
|
G1CollectedHeap* g1 = G1CollectedHeap::heap();
|
||||||
size_t nr = g1->num_free_regions();
|
size_t nr = g1->num_free_regions();
|
||||||
|
@ -318,6 +324,14 @@ WB_END
|
||||||
WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
|
WB_ENTRY(jint, WB_G1RegionSize(JNIEnv* env, jobject o))
|
||||||
return (jint)HeapRegion::GrainBytes;
|
return (jint)HeapRegion::GrainBytes;
|
||||||
WB_END
|
WB_END
|
||||||
|
|
||||||
|
WB_ENTRY(jobject, WB_G1AuxiliaryMemoryUsage(JNIEnv* env))
|
||||||
|
ResourceMark rm(THREAD);
|
||||||
|
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||||
|
MemoryUsage usage = g1h->get_auxiliary_data_memory_usage();
|
||||||
|
Handle h = MemoryService::create_MemoryUsage_obj(usage, CHECK_NULL);
|
||||||
|
return JNIHandles::make_local(env, h());
|
||||||
|
WB_END
|
||||||
#endif // INCLUDE_ALL_GCS
|
#endif // INCLUDE_ALL_GCS
|
||||||
|
|
||||||
#if INCLUDE_NMT
|
#if INCLUDE_NMT
|
||||||
|
@ -1240,9 +1254,12 @@ static JNINativeMethod methods[] = {
|
||||||
#if INCLUDE_ALL_GCS
|
#if INCLUDE_ALL_GCS
|
||||||
{CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark},
|
{CC"g1InConcurrentMark", CC"()Z", (void*)&WB_G1InConcurrentMark},
|
||||||
{CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous },
|
{CC"g1IsHumongous", CC"(Ljava/lang/Object;)Z", (void*)&WB_G1IsHumongous },
|
||||||
|
{CC"g1NumMaxRegions", CC"()J", (void*)&WB_G1NumMaxRegions },
|
||||||
{CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions },
|
{CC"g1NumFreeRegions", CC"()J", (void*)&WB_G1NumFreeRegions },
|
||||||
{CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize },
|
{CC"g1RegionSize", CC"()I", (void*)&WB_G1RegionSize },
|
||||||
{CC"g1StartConcMarkCycle", CC"()Z", (void*)&WB_G1StartMarkCycle },
|
{CC"g1StartConcMarkCycle", CC"()Z", (void*)&WB_G1StartMarkCycle },
|
||||||
|
{CC"g1AuxiliaryMemoryUsage", CC"()Ljava/lang/management/MemoryUsage;",
|
||||||
|
(void*)&WB_G1AuxiliaryMemoryUsage },
|
||||||
#endif // INCLUDE_ALL_GCS
|
#endif // INCLUDE_ALL_GCS
|
||||||
#if INCLUDE_NMT
|
#if INCLUDE_NMT
|
||||||
{CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc },
|
{CC"NMTMalloc", CC"(J)J", (void*)&WB_NMTMalloc },
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import static com.oracle.java.testlibrary.Asserts.assertLessThanOrEqual;
|
import com.oracle.java.testlibrary.Asserts;
|
||||||
import com.oracle.java.testlibrary.OutputAnalyzer;
|
import com.oracle.java.testlibrary.OutputAnalyzer;
|
||||||
import com.oracle.java.testlibrary.Platform;
|
import com.oracle.java.testlibrary.Platform;
|
||||||
import com.oracle.java.testlibrary.ProcessTools;
|
import com.oracle.java.testlibrary.ProcessTools;
|
||||||
|
@ -36,23 +36,29 @@ import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import sun.misc.Unsafe;
|
import sun.misc.Unsafe; // for ADDRESS_SIZE
|
||||||
|
import sun.hotspot.WhiteBox;
|
||||||
|
|
||||||
public class TestShrinkAuxiliaryData {
|
public class TestShrinkAuxiliaryData {
|
||||||
|
|
||||||
|
private static final int REGION_SIZE = 1024 * 1024;
|
||||||
|
|
||||||
private final static String[] initialOpts = new String[]{
|
private final static String[] initialOpts = new String[]{
|
||||||
"-XX:MinHeapFreeRatio=10",
|
"-XX:MinHeapFreeRatio=10",
|
||||||
"-XX:MaxHeapFreeRatio=11",
|
"-XX:MaxHeapFreeRatio=11",
|
||||||
"-XX:+UseG1GC",
|
"-XX:+UseG1GC",
|
||||||
"-XX:G1HeapRegionSize=1m",
|
"-XX:G1HeapRegionSize=" + REGION_SIZE,
|
||||||
"-XX:-ExplicitGCInvokesConcurrent",
|
"-XX:-ExplicitGCInvokesConcurrent",
|
||||||
"-XX:+PrintGCDetails"
|
"-XX:+PrintGCDetails",
|
||||||
|
"-XX:+UnlockDiagnosticVMOptions",
|
||||||
|
"-XX:+WhiteBoxAPI",
|
||||||
|
"-Xbootclasspath/a:.",
|
||||||
};
|
};
|
||||||
|
|
||||||
private final int RSetCacheSize;
|
private final int hotCardTableSize;
|
||||||
|
|
||||||
protected TestShrinkAuxiliaryData(int RSetCacheSize) {
|
protected TestShrinkAuxiliaryData(int hotCardTableSize) {
|
||||||
this.RSetCacheSize = RSetCacheSize;
|
this.hotCardTableSize = hotCardTableSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void test() throws Exception {
|
protected void test() throws Exception {
|
||||||
|
@ -60,16 +66,16 @@ public class TestShrinkAuxiliaryData {
|
||||||
Collections.addAll(vmOpts, initialOpts);
|
Collections.addAll(vmOpts, initialOpts);
|
||||||
|
|
||||||
int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize()));
|
int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize()));
|
||||||
if (maxCacheSize < RSetCacheSize) {
|
if (maxCacheSize < hotCardTableSize) {
|
||||||
System.out.format("Skiping test for %d cache size due max cache size %d",
|
System.out.format("Skiping test for %d cache size due max cache size %d",
|
||||||
RSetCacheSize, maxCacheSize
|
hotCardTableSize, maxCacheSize
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
printTestInfo(maxCacheSize);
|
printTestInfo(maxCacheSize);
|
||||||
|
|
||||||
vmOpts.add("-XX:G1ConcRSLogCacheSize=" + RSetCacheSize);
|
vmOpts.add("-XX:G1ConcRSLogCacheSize=" + hotCardTableSize);
|
||||||
vmOpts.addAll(Arrays.asList(Utils.getTestJavaOpts()));
|
vmOpts.addAll(Arrays.asList(Utils.getTestJavaOpts()));
|
||||||
|
|
||||||
// for 32 bits ObjectAlignmentInBytes is not a option
|
// for 32 bits ObjectAlignmentInBytes is not a option
|
||||||
|
@ -97,6 +103,8 @@ public class TestShrinkAuxiliaryData {
|
||||||
);
|
);
|
||||||
|
|
||||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||||
|
System.out.println(output.getStdout());
|
||||||
|
System.err.println(output.getStderr());
|
||||||
output.shouldHaveExitValue(0);
|
output.shouldHaveExitValue(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,12 +115,13 @@ public class TestShrinkAuxiliaryData {
|
||||||
formatSymbols.setGroupingSeparator(' ');
|
formatSymbols.setGroupingSeparator(' ');
|
||||||
grouped.setDecimalFormatSymbols(formatSymbols);
|
grouped.setDecimalFormatSymbols(formatSymbols);
|
||||||
|
|
||||||
System.out.format("Test will use %s bytes of memory of %s available%n"
|
System.out.format(
|
||||||
|
"Test will use %s bytes of memory of %s available%n"
|
||||||
+ "Available memory is %s with %d bytes pointer size - can save %s pointers%n"
|
+ "Available memory is %s with %d bytes pointer size - can save %s pointers%n"
|
||||||
+ "Max cache size: 2^%d = %s elements%n",
|
+ "Max cache size: 2^%d = %s elements%n",
|
||||||
grouped.format(ShrinkAuxiliaryDataTest.getMemoryUsedByTest()),
|
grouped.format(ShrinkAuxiliaryDataTest.getMemoryUsedByTest()),
|
||||||
grouped.format(Runtime.getRuntime().freeMemory()),
|
grouped.format(Runtime.getRuntime().maxMemory()),
|
||||||
grouped.format(Runtime.getRuntime().freeMemory()
|
grouped.format(Runtime.getRuntime().maxMemory()
|
||||||
- ShrinkAuxiliaryDataTest.getMemoryUsedByTest()),
|
- ShrinkAuxiliaryDataTest.getMemoryUsedByTest()),
|
||||||
Unsafe.ADDRESS_SIZE,
|
Unsafe.ADDRESS_SIZE,
|
||||||
grouped.format((Runtime.getRuntime().freeMemory()
|
grouped.format((Runtime.getRuntime().freeMemory()
|
||||||
|
@ -135,6 +144,7 @@ public class TestShrinkAuxiliaryData {
|
||||||
if (availableMemory <= 0) {
|
if (availableMemory <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long availablePointersCount = availableMemory / Unsafe.ADDRESS_SIZE;
|
long availablePointersCount = availableMemory / Unsafe.ADDRESS_SIZE;
|
||||||
return (63 - (int) Long.numberOfLeadingZeros(availablePointersCount));
|
return (63 - (int) Long.numberOfLeadingZeros(availablePointersCount));
|
||||||
}
|
}
|
||||||
|
@ -142,17 +152,48 @@ public class TestShrinkAuxiliaryData {
|
||||||
static class ShrinkAuxiliaryDataTest {
|
static class ShrinkAuxiliaryDataTest {
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
int iterateCount = DEFAULT_ITERATION_COUNT;
|
|
||||||
|
|
||||||
if (args.length > 0) {
|
ShrinkAuxiliaryDataTest testCase = new ShrinkAuxiliaryDataTest();
|
||||||
try {
|
|
||||||
iterateCount = Integer.parseInt(args[0]);
|
if (!testCase.checkEnvApplicability()) {
|
||||||
} catch (NumberFormatException e) {
|
return;
|
||||||
//num_iterate remains default
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
new ShrinkAuxiliaryDataTest().test(iterateCount);
|
testCase.test();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks is this environment suitable to run this test
|
||||||
|
* - memory is enough to decommit (page size is not big)
|
||||||
|
* - RSet cache size is not too big
|
||||||
|
*
|
||||||
|
* @return true if test could run, false if test should be skipped
|
||||||
|
*/
|
||||||
|
protected boolean checkEnvApplicability() {
|
||||||
|
|
||||||
|
int pageSize = WhiteBox.getWhiteBox().getVMPageSize();
|
||||||
|
System.out.println( "Page size = " + pageSize
|
||||||
|
+ " region size = " + REGION_SIZE
|
||||||
|
+ " aux data ~= " + (REGION_SIZE * 3 / 100));
|
||||||
|
// If auxdata size will be less than page size it wouldn't decommit.
|
||||||
|
// Auxiliary data size is about ~3.6% of heap size.
|
||||||
|
if (pageSize >= REGION_SIZE * 3 / 100) {
|
||||||
|
System.out.format("Skipping test for too large page size = %d",
|
||||||
|
pageSize
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (REGION_SIZE * REGIONS_TO_ALLOCATE > Runtime.getRuntime().maxMemory()) {
|
||||||
|
System.out.format("Skipping test for too low available memory. "
|
||||||
|
+ "Need %d, available %d",
|
||||||
|
REGION_SIZE * REGIONS_TO_ALLOCATE,
|
||||||
|
Runtime.getRuntime().maxMemory()
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
class GarbageObject {
|
class GarbageObject {
|
||||||
|
@ -177,41 +218,54 @@ public class TestShrinkAuxiliaryData {
|
||||||
|
|
||||||
private final List<GarbageObject> garbage = new ArrayList();
|
private final List<GarbageObject> garbage = new ArrayList();
|
||||||
|
|
||||||
public void test(int num_iterate) throws IOException {
|
public void test() throws IOException {
|
||||||
|
|
||||||
|
MemoryUsage muFull, muFree, muAuxDataFull, muAuxDataFree;
|
||||||
|
float auxFull, auxFree;
|
||||||
|
|
||||||
allocate();
|
allocate();
|
||||||
link();
|
link();
|
||||||
mutate();
|
mutate();
|
||||||
|
|
||||||
|
muFull = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||||
|
long numUsedRegions = WhiteBox.getWhiteBox().g1NumMaxRegions()
|
||||||
|
- WhiteBox.getWhiteBox().g1NumFreeRegions();
|
||||||
|
muAuxDataFull = WhiteBox.getWhiteBox().g1AuxiliaryMemoryUsage();
|
||||||
|
auxFull = (float)muAuxDataFull.getUsed() / numUsedRegions;
|
||||||
|
|
||||||
|
System.out.format("Full aux data ratio= %f, regions max= %d, used= %d\n",
|
||||||
|
auxFull, WhiteBox.getWhiteBox().g1NumMaxRegions(), numUsedRegions
|
||||||
|
);
|
||||||
|
|
||||||
deallocate();
|
deallocate();
|
||||||
|
|
||||||
MemoryUsage muBeforeHeap
|
|
||||||
= ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
|
||||||
MemoryUsage muBeforeNonHeap
|
|
||||||
= ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
|
|
||||||
|
|
||||||
for (int i = 0; i < num_iterate; i++) {
|
|
||||||
allocate();
|
|
||||||
link();
|
|
||||||
mutate();
|
|
||||||
deallocate();
|
|
||||||
}
|
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
MemoryUsage muAfterHeap
|
|
||||||
= ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
|
||||||
MemoryUsage muAfterNonHeap
|
|
||||||
= ManagementFactory.getMemoryMXBean().getNonHeapMemoryUsage();
|
|
||||||
|
|
||||||
assertLessThanOrEqual(muAfterHeap.getCommitted(), muBeforeHeap.getCommitted(),
|
muFree = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
|
||||||
String.format("heap decommit failed - after > before: %d > %d",
|
muAuxDataFree = WhiteBox.getWhiteBox().g1AuxiliaryMemoryUsage();
|
||||||
muAfterHeap.getCommitted(), muBeforeHeap.getCommitted()
|
|
||||||
|
numUsedRegions = WhiteBox.getWhiteBox().g1NumMaxRegions()
|
||||||
|
- WhiteBox.getWhiteBox().g1NumFreeRegions();
|
||||||
|
auxFree = (float)muAuxDataFree.getUsed() / numUsedRegions;
|
||||||
|
|
||||||
|
System.out.format("Free aux data ratio= %f, regions max= %d, used= %d\n",
|
||||||
|
auxFree, WhiteBox.getWhiteBox().g1NumMaxRegions(), numUsedRegions
|
||||||
|
);
|
||||||
|
|
||||||
|
Asserts.assertLessThanOrEqual(muFree.getCommitted(), muFull.getCommitted(),
|
||||||
|
String.format("heap decommit failed - full > free: %d > %d",
|
||||||
|
muFree.getCommitted(), muFull.getCommitted()
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (muAfterHeap.getCommitted() < muBeforeHeap.getCommitted()) {
|
System.out.format("State used committed\n");
|
||||||
assertLessThanOrEqual(muAfterNonHeap.getCommitted(), muBeforeNonHeap.getCommitted(),
|
System.out.format("Full aux data: %10d %10d\n", muAuxDataFull.getUsed(), muAuxDataFull.getCommitted());
|
||||||
String.format("non-heap decommit failed - after > before: %d > %d",
|
System.out.format("Free aux data: %10d %10d\n", muAuxDataFree.getUsed(), muAuxDataFree.getCommitted());
|
||||||
muAfterNonHeap.getCommitted(), muBeforeNonHeap.getCommitted()
|
|
||||||
|
// if decommited check that aux data has same ratio
|
||||||
|
if (muFree.getCommitted() < muFull.getCommitted()) {
|
||||||
|
Asserts.assertLessThanOrEqual(auxFree, auxFull,
|
||||||
|
String.format("auxiliary data decommit failed - full > free: %f > %f",
|
||||||
|
auxFree, auxFull
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -238,8 +292,7 @@ public class TestShrinkAuxiliaryData {
|
||||||
for (int i = 0; i < NUM_LINKS; i++) {
|
for (int i = 0; i < NUM_LINKS; i++) {
|
||||||
int regionToLink;
|
int regionToLink;
|
||||||
do {
|
do {
|
||||||
regionToLink = (int) (Math.random()
|
regionToLink = (int) (Math.random() * REGIONS_TO_ALLOCATE);
|
||||||
* REGIONS_TO_ALLOCATE);
|
|
||||||
} while (regionToLink == regionNumber);
|
} while (regionToLink == regionNumber);
|
||||||
|
|
||||||
// get random garbage object from random region
|
// get random garbage object from random region
|
||||||
|
@ -265,11 +318,8 @@ public class TestShrinkAuxiliaryData {
|
||||||
return REGIONS_TO_ALLOCATE * REGION_SIZE;
|
return REGIONS_TO_ALLOCATE * REGION_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final int REGION_SIZE = 1024 * 1024;
|
private static final int REGIONS_TO_ALLOCATE = 100;
|
||||||
private static final int DEFAULT_ITERATION_COUNT = 1; // iterate main scenario
|
|
||||||
private static final int REGIONS_TO_ALLOCATE = 5;
|
|
||||||
private static final int NUM_OBJECTS_PER_REGION = 10;
|
private static final int NUM_OBJECTS_PER_REGION = 10;
|
||||||
private static final int NUM_LINKS = 20; // how many links create for each object
|
private static final int NUM_LINKS = 20; // how many links create for each object
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -23,11 +23,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test TestShrinkAuxiliaryData00
|
* @test TestShrinkAuxiliaryData00
|
||||||
* @bug 8038423
|
* @bug 8038423 8061715
|
||||||
* @summary Checks that decommitment occurs for JVM with different
|
* @summary Checks that decommitment occurs for JVM with different
|
||||||
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
||||||
|
* @requires vm.gc=="G1" | vm.gc=="null"
|
||||||
* @library /testlibrary /../../test/lib
|
* @library /testlibrary /../../test/lib
|
||||||
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData00
|
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
|
||||||
|
* TestShrinkAuxiliaryData TestShrinkAuxiliaryData00
|
||||||
|
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||||
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||||
* @run driver/timeout=720 TestShrinkAuxiliaryData00
|
* @run driver/timeout=720 TestShrinkAuxiliaryData00
|
||||||
*/
|
*/
|
||||||
public class TestShrinkAuxiliaryData00 {
|
public class TestShrinkAuxiliaryData00 {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -23,12 +23,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test TestShrinkAuxiliaryData05
|
* @test TestShrinkAuxiliaryData05
|
||||||
* @bug 8038423
|
* @bug 8038423 8061715
|
||||||
* @summary Checks that decommitment occurs for JVM with different
|
* @summary Checks that decommitment occurs for JVM with different
|
||||||
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
||||||
* @requires vm.gc=="G1" | vm.gc=="null"
|
* @requires vm.gc=="G1" | vm.gc=="null"
|
||||||
* @library /testlibrary /../../test/lib
|
* @library /testlibrary /../../test/lib
|
||||||
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData05
|
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
|
||||||
|
* TestShrinkAuxiliaryData TestShrinkAuxiliaryData05
|
||||||
|
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||||
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||||
* @run driver/timeout=720 TestShrinkAuxiliaryData05
|
* @run driver/timeout=720 TestShrinkAuxiliaryData05
|
||||||
*/
|
*/
|
||||||
public class TestShrinkAuxiliaryData05 {
|
public class TestShrinkAuxiliaryData05 {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -23,12 +23,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test TestShrinkAuxiliaryData10
|
* @test TestShrinkAuxiliaryData10
|
||||||
* @bug 8038423
|
* @bug 8038423 8061715
|
||||||
* @summary Checks that decommitment occurs for JVM with different
|
* @summary Checks that decommitment occurs for JVM with different
|
||||||
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
||||||
* @requires vm.gc=="G1" | vm.gc=="null"
|
* @requires vm.gc=="G1" | vm.gc=="null"
|
||||||
* @library /testlibrary /../../test/lib
|
* @library /testlibrary /../../test/lib
|
||||||
|
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
|
||||||
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData10
|
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData10
|
||||||
|
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||||
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||||
* @run driver/timeout=720 TestShrinkAuxiliaryData10
|
* @run driver/timeout=720 TestShrinkAuxiliaryData10
|
||||||
*/
|
*/
|
||||||
public class TestShrinkAuxiliaryData10 {
|
public class TestShrinkAuxiliaryData10 {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -23,12 +23,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test TestShrinkAuxiliaryData15
|
* @test TestShrinkAuxiliaryData15
|
||||||
* @bug 8038423
|
* @bug 8038423 8061715
|
||||||
* @summary Checks that decommitment occurs for JVM with different
|
* @summary Checks that decommitment occurs for JVM with different
|
||||||
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
||||||
* @requires vm.gc=="G1" | vm.gc=="null"
|
* @requires vm.gc=="G1" | vm.gc=="null"
|
||||||
* @library /testlibrary /../../test/lib
|
* @library /testlibrary /../../test/lib
|
||||||
|
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
|
||||||
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData15
|
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData15
|
||||||
|
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||||
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||||
* @run driver/timeout=720 TestShrinkAuxiliaryData15
|
* @run driver/timeout=720 TestShrinkAuxiliaryData15
|
||||||
*/
|
*/
|
||||||
public class TestShrinkAuxiliaryData15 {
|
public class TestShrinkAuxiliaryData15 {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -23,12 +23,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test TestShrinkAuxiliaryData20
|
* @test TestShrinkAuxiliaryData20
|
||||||
* @bug 8038423
|
* @bug 8038423 8061715
|
||||||
* @summary Checks that decommitment occurs for JVM with different
|
* @summary Checks that decommitment occurs for JVM with different
|
||||||
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
||||||
* @requires vm.gc=="G1" | vm.gc=="null"
|
* @requires vm.gc=="G1" | vm.gc=="null"
|
||||||
* @library /testlibrary /../../test/lib
|
* @library /testlibrary /../../test/lib
|
||||||
|
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
|
||||||
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData20
|
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData20
|
||||||
|
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||||
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||||
* @run driver/timeout=720 TestShrinkAuxiliaryData20
|
* @run driver/timeout=720 TestShrinkAuxiliaryData20
|
||||||
*/
|
*/
|
||||||
public class TestShrinkAuxiliaryData20 {
|
public class TestShrinkAuxiliaryData20 {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -23,12 +23,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test TestShrinkAuxiliaryData25
|
* @test TestShrinkAuxiliaryData25
|
||||||
* @bug 8038423
|
* @bug 8038423 8061715
|
||||||
* @summary Checks that decommitment occurs for JVM with different
|
* @summary Checks that decommitment occurs for JVM with different
|
||||||
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
||||||
* @requires vm.gc=="G1" | vm.gc=="null"
|
* @requires vm.gc=="G1" | vm.gc=="null"
|
||||||
* @library /testlibrary /../../test/lib
|
* @library /testlibrary /../../test/lib
|
||||||
|
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
|
||||||
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData25
|
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData25
|
||||||
|
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||||
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||||
* @run driver/timeout=720 TestShrinkAuxiliaryData25
|
* @run driver/timeout=720 TestShrinkAuxiliaryData25
|
||||||
*/
|
*/
|
||||||
public class TestShrinkAuxiliaryData25 {
|
public class TestShrinkAuxiliaryData25 {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2014, 2015, 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
|
||||||
|
@ -23,12 +23,15 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test TestShrinkAuxiliaryData30
|
* @test TestShrinkAuxiliaryData30
|
||||||
* @bug 8038423
|
* @bug 8038423 8061715
|
||||||
* @summary Checks that decommitment occurs for JVM with different
|
* @summary Checks that decommitment occurs for JVM with different
|
||||||
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
|
||||||
* @requires vm.gc=="G1" | vm.gc=="null"
|
* @requires vm.gc=="G1" | vm.gc=="null"
|
||||||
* @library /testlibrary /../../test/lib
|
* @library /testlibrary /../../test/lib
|
||||||
|
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
|
||||||
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData30
|
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData30
|
||||||
|
* @run main ClassFileInstaller sun.hotspot.WhiteBox
|
||||||
|
* sun.hotspot.WhiteBox$WhiteBoxPermission
|
||||||
* @run driver/timeout=720 TestShrinkAuxiliaryData30
|
* @run driver/timeout=720 TestShrinkAuxiliaryData30
|
||||||
*/
|
*/
|
||||||
public class TestShrinkAuxiliaryData30 {
|
public class TestShrinkAuxiliaryData30 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue