Renamed the destroyByteBuffer method to destroyDirectBuffer
because it more appropriately says what it does and this is a relatively new method. After changing it to work with any direct buffer it seemed inappropriately named. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9121 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
9ecaf0b96e
commit
ebb2fca18f
@ -1145,18 +1145,18 @@ public final class BufferUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* DirectByteBuffers are garbage collected by using a phantom reference and a
|
||||
* Direct buffers 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.
|
||||
* cleans the direct buffers. However, as this doesn't happen
|
||||
* immediately after discarding all references to a direct buffer, it's
|
||||
* easy to OutOfMemoryError yourself using direct buffers. This function
|
||||
* explicitly calls the Cleaner method of a direct buffer.
|
||||
*
|
||||
* @param toBeDestroyed
|
||||
* The DirectByteBuffer that will be "cleaned". Utilizes reflection.
|
||||
* The direct buffer that will be "cleaned". Utilizes reflection.
|
||||
*
|
||||
*/
|
||||
public static void destroyByteBuffer(Buffer toBeDestroyed) {
|
||||
public static void destroyDirectBuffer(Buffer toBeDestroyed) {
|
||||
|
||||
if (!toBeDestroyed.isDirect()) {
|
||||
return;
|
||||
|
@ -60,7 +60,7 @@ public class TestReleaseDirectMemory extends SimpleApplication {
|
||||
@Override
|
||||
public void simpleUpdate(float tpf) {
|
||||
ByteBuffer buf = BufferUtils.createByteBuffer(500000);
|
||||
BufferUtils.destroyByteBuffer(buf);
|
||||
BufferUtils.destroyDirectBuffer(buf);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user