--- old/src/java.base/share/classes/java/nio/Bits.java 2016-04-01 18:43:50.118989058 +0200 +++ new/src/java.base/share/classes/java/nio/Bits.java 2016-04-01 18:43:50.026988475 +0200 @@ -29,10 +29,8 @@ import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.Unsafe; import jdk.internal.misc.VM; -import jdk.internal.ref.CleanerFactory; import java.util.concurrent.atomic.AtomicLong; -import java.util.function.BooleanSupplier; /** * Access to bits, native and otherwise. @@ -607,27 +605,13 @@ // These methods should be called whenever direct memory is allocated or // freed. They allow the user to control the amount of direct memory // which a process may access. All sizes are specified in bytes. - static void reserveMemory(long size, int cap) { + static boolean tryReserveMemory(long size, int cap) { if (!memoryLimitSet && VM.initLevel() >= 1) { maxMemory = VM.maxDirectMemory(); memoryLimitSet = true; } - if (!CleanerFactory.dbbCleaner().retryWhileHelpingClean( - new BooleanSupplier() { - @Override - public boolean getAsBoolean() { - return tryReserveMemory(size, cap); - } - })) { - // no luck - throw new OutOfMemoryError("Direct buffer memory"); - } - } - - private static boolean tryReserveMemory(long size, int cap) { - // -XX:MaxDirectMemorySize limits the total capacity rather than the // actual memory usage, which will differ when buffers are page // aligned.