destroyDirectByteBuffer
public static void destroyDirectByteBuffer(ByteBuffer toBeDestroyed)
throws IllegalArgumentException,
IllegalAccessException,
InvocationTargetException,
SecurityException,
NoSuchMethodException
DirectByteBuffers are garbage collected by using a phantom reference and a
reference queue. Every once a while, the JVM checks the reference queue and
cleans the DirectByteBuffers. However, as this doesn't happen
immediately after discarding all references to a DirectByteBuffer, it's
easy to OutOfMemoryError yourself using DirectByteBuffers. This function
explicitly calls the Cleaner method of a DirectByteBuffer.
- Parameters:
toBeDestroyed
- The DirectByteBuffer that will be "cleaned". Utilizes reflection.
- Throws:
IllegalArgumentException
IllegalAccessException
InvocationTargetException
SecurityException
NoSuchMethodException