final class ByteBufferCleaner
extends java.lang.Object
ByteBuffer. 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 ByteBuffer that 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
| Modifier and Type | Class and Description |
|---|---|
private static interface |
ByteBufferCleaner.Cleaner |
private static class |
ByteBufferCleaner.Java8Cleaner |
private static class |
ByteBufferCleaner.Java9Cleaner |
| Modifier and Type | Field and Description |
|---|---|
private static ByteBufferCleaner.Cleaner |
INSTANCE |
| Constructor and Description |
|---|
ByteBufferCleaner() |
| Modifier and Type | Method and Description |
|---|---|
(package private) static void |
clean(java.nio.ByteBuffer buffer)
Releases memory held by the given
ByteBuffer. |
private static ByteBufferCleaner.Cleaner |
getCleaner() |
(package private) static boolean |
isSupported()
Tests if were able to load a suitable cleaner for the current JVM.
|
private static final ByteBufferCleaner.Cleaner INSTANCE
static void clean(java.nio.ByteBuffer buffer)
ByteBuffer.buffer - to release.java.lang.IllegalStateException - on internal failure.private static ByteBufferCleaner.Cleaner getCleaner()
static boolean isSupported()
ByteBufferCleaner#clean(ByteBuffer) when this method returns false will result in an exception.true if cleaning is supported, false otherwise.