org.apache.hadoop.hbase.util
Class DirectMemoryUtils

java.lang.Object
  extended by org.apache.hadoop.hbase.util.DirectMemoryUtils

public class DirectMemoryUtils
extends Object


Constructor Summary
DirectMemoryUtils()
           
 
Method Summary
static void destroyDirectByteBuffer(ByteBuffer toBeDestroyed)
          DirectByteBuffers are garbage collected by using a phantom reference and a reference queue.
static long getDirectMemorySize()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DirectMemoryUtils

public DirectMemoryUtils()
Method Detail

getDirectMemorySize

public static long getDirectMemorySize()
Returns:
the setting of -XX:MaxDirectMemorySize as a long. Returns 0 if -XX:MaxDirectMemorySize is not set.

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


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.