Build 1.0_r1(from source)

java.nio
Class DirectByteBuffers

java.lang.Object
  extended by java.nio.DirectByteBuffers

 class DirectByteBuffers
extends Object

Helper class for operations on direct ByteBuffer

See Also:
ByteBuffer

Constructor Summary
DirectByteBuffers()
           
 
Method Summary
static void free(ByteBuffer directBuffer)
          Explicitly frees the memory used by the given direct byte buffer.
static org.apache.harmony.luni.platform.PlatformAddress getEffectiveAddress(ByteBuffer directBuffer)
          Returns the platform address of the start of this buffer instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectByteBuffers

DirectByteBuffers()
Method Detail

free

public static void free(ByteBuffer directBuffer)
Explicitly frees the memory used by the given direct byte buffer.

If the memory is known to already have been freed then this is a no-op. Once the memory has been freed then operations requiring access to the memory will throw an IllegalStateException.

Note this is is possible that the memory is freed by code that reaches into the address and explicitly frees it 'beneith' us -- this is bad form.

Parameters:
directBuffer - the direct byte buffer memory to free
Throws:
IllegalArgumentException - if the buffer is null or is not a direct byte buffer.

getEffectiveAddress

public static org.apache.harmony.luni.platform.PlatformAddress getEffectiveAddress(ByteBuffer directBuffer)
Returns the platform address of the start of this buffer instance. You must not attempt to free the returned address!! It may not be an address that was explicitly malloc'ed (i.e. if this buffer is the result of a split); and it may be memory shared by multiple buffers.

If you can guarantee that you want to free the underlying memory call the #free() method on this instance -- generally applications will rely on the garbage collector to autofree this memory.

Parameters:
directBuffer - the direct byte buffer
Returns:
the effective address of the start of the buffer.
Throws:
IllegalStateException - if this buffer address is known to have been freed previously.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature