提交 42c47a3b 编写于 作者: J jbachorik

8034263: Test java/lang/management/MemoryMXBean/LowMemoryTest.java fails intermittently

Reviewed-by: sla
上级 465ec5e1
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2014, 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
......@@ -35,11 +35,13 @@
* @run main/timeout=600 LowMemoryTest
*/
import com.sun.management.DiagnosticCommandMBean;
import java.lang.management.*;
import java.util.*;
import java.util.concurrent.Phaser;
import javax.management.*;
import javax.management.openmbean.CompositeData;
import sun.management.ManagementFactoryHelper;
public class LowMemoryTest {
private static final MemoryMXBean mm = ManagementFactory.getMemoryMXBean();
......@@ -85,9 +87,15 @@ public class LowMemoryTest {
}
static class TestListener implements NotificationListener {
private boolean isRelaxed = false;
private int triggers = 0;
private final long[] count = new long[NUM_TRIGGERS * 2];
private final long[] usedMemory = new long[NUM_TRIGGERS * 2];
public TestListener() {
isRelaxed = ManagementFactory.getRuntimeMXBean().getInputArguments().contains("-XX:+UseConcMarkSweepGC");
}
@Override
public void handleNotification(Notification notif, Object handback) {
MemoryNotificationInfo minfo = MemoryNotificationInfo.
......@@ -97,7 +105,8 @@ public class LowMemoryTest {
triggers++;
}
public void checkResult() throws Exception {
if (triggers != NUM_TRIGGERS) {
if ((!isRelaxed && triggers != NUM_TRIGGERS) ||
(isRelaxed && triggers < NUM_TRIGGERS)) {
throw new RuntimeException("Unexpected number of triggers = " +
triggers + " but expected to be " + NUM_TRIGGERS);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册