< prev index next >
src/java.base/share/classes/java/nio/Bits.java
Print this page
@@ -27,14 +27,12 @@
import jdk.internal.misc.JavaNioAccess;
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.
*/
@@ -605,31 +603,17 @@
private static volatile boolean memoryLimitSet;
// 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.
long totalCap;
while (cap <= maxMemory - (totalCap = totalCapacity.get())) {
< prev index next >