test framework: prevent negative array size on large heaps
authorRoman Shevchenko <roman.shevchenko@jetbrains.com>
Thu, 29 Jan 2015 13:21:48 +0000 (16:21 +0300)
committerRoman Shevchenko <roman.shevchenko@jetbrains.com>
Thu, 29 Jan 2015 13:21:48 +0000 (16:21 +0300)
platform/testFramework/src/com/intellij/util/GCUtil.java

index 6c1762a7f2f21e61f1a5a593795fa0c4997ad033..610537beffa0d665ffa05785116fa7f58c49febd 100644 (file)
@@ -52,7 +52,8 @@ public class GCUtil {
       if (q.poll() != null) {
         break;
       }
-      list.add(new SoftReference<byte[]>(new byte[(int)Runtime.getRuntime().freeMemory() / 2]));
+      long bytes = Math.min(Runtime.getRuntime().freeMemory() / 2, Integer.MAX_VALUE);
+      list.add(new SoftReference<byte[]>(new byte[(int)bytes]));
     }
   }