Fixed FloatBuffer support as well as other
buffers that are views of other buffers and follow the same conventions. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9127 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
33156837bf
commit
4edf262021
@ -1165,9 +1165,21 @@ public final class BufferUtils {
|
||||
Method cleanerMethod = toBeDestroyed.getClass().getMethod("cleaner");
|
||||
cleanerMethod.setAccessible(true);
|
||||
Object cleaner = cleanerMethod.invoke(toBeDestroyed);
|
||||
if (cleaner != null) {
|
||||
Method cleanMethod = cleaner.getClass().getMethod("clean");
|
||||
cleanMethod.setAccessible(true);
|
||||
cleanMethod.invoke(cleaner);
|
||||
} else {
|
||||
// Try the alternate approach of getting the viewed buffer
|
||||
Method viewedBufferMethod = toBeDestroyed.getClass().getMethod("viewedBuffer");
|
||||
viewedBufferMethod.setAccessible(true);
|
||||
Object viewedBuffer = viewedBufferMethod.invoke(toBeDestroyed);
|
||||
if (viewedBuffer != null) {
|
||||
destroyDirectBuffer( (Buffer)viewedBuffer );
|
||||
} else {
|
||||
Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE, "Buffer cannot be destroyed: {0}", toBeDestroyed);
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException ex) {
|
||||
Logger.getLogger(BufferUtils.class.getName()).log(Level.SEVERE, "{0}", ex);
|
||||
} catch (IllegalArgumentException ex) {
|
||||
|
@ -39,6 +39,7 @@ import com.jme3.scene.Geometry;
|
||||
import com.jme3.scene.shape.Box;
|
||||
import com.jme3.util.BufferUtils;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
|
||||
public class TestReleaseDirectMemory extends SimpleApplication {
|
||||
|
||||
@ -61,6 +62,9 @@ public class TestReleaseDirectMemory extends SimpleApplication {
|
||||
public void simpleUpdate(float tpf) {
|
||||
ByteBuffer buf = BufferUtils.createByteBuffer(500000);
|
||||
BufferUtils.destroyDirectBuffer(buf);
|
||||
|
||||
FloatBuffer buf2 = BufferUtils.createFloatBuffer(500000);
|
||||
BufferUtils.destroyDirectBuffer(buf2);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user