commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1084639 - /commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
Date Wed, 23 Mar 2011 17:02:42 GMT
Author: markt
Date: Wed Mar 23 17:02:42 2011
New Revision: 1084639

URL: http://svn.apache.org/viewvc?rev=1084639&view=rev
Log:
Prevent test failures on machines with lots of ram

Modified:
    commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java

Modified: commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
URL: http://svn.apache.org/viewvc/commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java?rev=1084639&r1=1084638&r2=1084639&view=diff
==============================================================================
--- commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
(original)
+++ commons/proper/pool/branches/POOL_1_X/src/test/org/apache/commons/pool/impl/TestSoftRefOutOfMemory.java
Wed Mar 23 17:02:42 2011
@@ -60,7 +60,11 @@ public class TestSoftRefOutOfMemory exte
         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();
             }
@@ -95,7 +99,11 @@ public class TestSoftRefOutOfMemory exte
         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();
             }
@@ -126,7 +134,11 @@ public class TestSoftRefOutOfMemory exte
         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();
             }



Mime
View raw message