You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2011/03/23 18:04:22 UTC
svn commit: r1084640 -
/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/ref/TestSoftRefOutOfMemory.java
Author: markt
Date: Wed Mar 23 17:04:22 2011
New Revision: 1084640
URL: http://svn.apache.org/viewvc?rev=1084640&view=rev
Log:
Prevent test failures on machines with lots of ram
Modified:
commons/proper/pool/trunk/src/test/org/apache/commons/pool2/ref/TestSoftRefOutOfMemory.java
Modified: commons/proper/pool/trunk/src/test/org/apache/commons/pool2/ref/TestSoftRefOutOfMemory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/trunk/src/test/org/apache/commons/pool2/ref/TestSoftRefOutOfMemory.java?rev=1084640&r1=1084639&r2=1084640&view=diff
==============================================================================
--- commons/proper/pool/trunk/src/test/org/apache/commons/pool2/ref/TestSoftRefOutOfMemory.java (original)
+++ commons/proper/pool/trunk/src/test/org/apache/commons/pool2/ref/TestSoftRefOutOfMemory.java Wed Mar 23 17:04:22 2011
@@ -63,7 +63,11 @@ public class TestSoftRefOutOfMemory {
final Runtime runtime = Runtime.getRuntime();
while (pool.getNumIdle() > 0) {
try {
- garbage.add(new byte[Math.min(1024 * 1024, (int)runtime.freeMemory()/2)]);
+ long freeMemory = runtime.freeMemory();
+ if (freeMemory > Integer.MAX_VALUE) {
+ freeMemory = Integer.MAX_VALUE;
+ }
+ garbage.add(new byte[Math.min(1024 * 1024, (int)freeMemory/2)]);
} catch (OutOfMemoryError oome) {
System.gc();
}
@@ -99,7 +103,11 @@ public class TestSoftRefOutOfMemory {
final Runtime runtime = Runtime.getRuntime();
while (pool.getNumIdle() > 0) {
try {
- garbage.add(new byte[Math.min(1024 * 1024, (int)runtime.freeMemory()/2)]);
+ long freeMemory = runtime.freeMemory();
+ if (freeMemory > Integer.MAX_VALUE) {
+ freeMemory = Integer.MAX_VALUE;
+ }
+ garbage.add(new byte[Math.min(1024 * 1024, (int)freeMemory/2)]);
} catch (OutOfMemoryError oome) {
System.gc();
}
@@ -131,7 +139,11 @@ public class TestSoftRefOutOfMemory {
final Runtime runtime = Runtime.getRuntime();
while (pool.getNumIdle() > 0) {
try {
- garbage.add(new byte[Math.min(1024 * 1024, (int)runtime.freeMemory()/2)]);
+ long freeMemory = runtime.freeMemory();
+ if (freeMemory > Integer.MAX_VALUE) {
+ freeMemory = Integer.MAX_VALUE;
+ }
+ garbage.add(new byte[Math.min(1024 * 1024, (int)freeMemory/2)]);
} catch (OutOfMemoryError oome) {
System.gc();
}