Package org.apache.commons.io.input
Class ByteBufferCleaner
- java.lang.Object
-
- org.apache.commons.io.input.ByteBufferCleaner
-
final class ByteBufferCleaner extends java.lang.ObjectCleans a directByteBuffer. Without manual intervention, direct ByteBuffers will be cleaned eventually upon garbage collection. However, this should not be relied upon since it may not occur in a timely fashion - especially since off heap ByeBuffers don't put pressure on the garbage collector.Warning: Do not attempt to use a direct
ByteBufferthat has been cleaned or bad things will happen. Don't use this class unless you can ensure that the cleaned buffer will not be accessed anymore.See JDK-4724038
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static interfaceByteBufferCleaner.Cleanerprivate static classByteBufferCleaner.Java8Cleanerprivate static classByteBufferCleaner.Java9Cleaner
-
Field Summary
Fields Modifier and Type Field Description private static ByteBufferCleaner.CleanerINSTANCE
-
Constructor Summary
Constructors Constructor Description ByteBufferCleaner()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static voidclean(java.nio.ByteBuffer buffer)Releases memory held by the givenByteBuffer.private static ByteBufferCleaner.CleanergetCleaner()(package private) static booleanisSupported()Tests if were able to load a suitable cleaner for the current JVM.
-
-
-
Field Detail
-
INSTANCE
private static final ByteBufferCleaner.Cleaner INSTANCE
-
-
Method Detail
-
clean
static void clean(java.nio.ByteBuffer buffer)
Releases memory held by the givenByteBuffer.- Parameters:
buffer- to release.- Throws:
java.lang.IllegalStateException- on internal failure.
-
getCleaner
private static ByteBufferCleaner.Cleaner getCleaner()
-
isSupported
static boolean isSupported()
Tests if were able to load a suitable cleaner for the current JVM. Attempting to callByteBufferCleaner#clean(ByteBuffer)when this method returns false will result in an exception.- Returns:
trueif cleaning is supported,falseotherwise.
-
-