org.apache.hadoop.hbase.util
Class DirectMemoryUtils
java.lang.Object
org.apache.hadoop.hbase.util.DirectMemoryUtils
@InterfaceAudience.Private
@InterfaceStability.Evolving
public class DirectMemoryUtils
- extends Object
Utilities for interacting with and monitoring DirectByteBuffer allocations.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DirectMemoryUtils
public DirectMemoryUtils()
getDirectMemorySize
public static long getDirectMemorySize()
- Returns:
- the setting of -XX:MaxDirectMemorySize as a long. Returns 0 if
-XX:MaxDirectMemorySize is not set.
getDirectMemoryUsage
public static long getDirectMemoryUsage()
- Returns:
- the current amount of direct memory used.
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 © 2007-2016 The Apache Software Foundation. All Rights Reserved.