Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Hello,
in jogl es2 i use direct java.nio.FloatBuffer for vertices and direct java.nio.ByteBuffer for Bytedata of Texture. If i don't need some Texture anymore, i delete it in this way: gl.glDeleteTextures( 1, new int[] { textureId }, 0 ); gl.glDeleteBuffers(1, new int[] { vboId }, 0); and Buffers with sun.misc.Cleaner Delete of ByteBuffer is sucessful, but FloatBuffer is still here. How can i delete FloatBuffer? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Hi
You have to get the view of the direct float buffer. It's in sun.nio.ch.DirectBuffer.viewedBuffer in Java 1.6 and sun.nio.ch.DirectBuffer.attachment in Java 1.7 and later. Use the reflection API. This field contains a direct byte buffer used under the hood. Edit.: I hope you use this class to create your buffers: http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/nio/Buffers.html
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Yes, i create Buffers with com.jogamp.common.nio.Buffers.java
Thank you for advice! It works now. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
You're welcome. Just as a reminder, this feature is implemented in JMonkeyEngine 3 and you have to call another method when using Apache Harmony (including Dalvik VM).
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I use RasPi with Oracle JDK 1.8.0, so i don't need Dalvik VM.
I have found, how JME deletes Buffers in https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/util/BufferUtils.java#L1307 and i follow your answer in http://stackoverflow.com/a/26777380 But its seems like the DirectBuffers would not clear all the time. The native heap grows slowly... |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
You can use a plugin of JVisualVM to see the native memory usage and look at the direct NIO buffers.
No the direct NIO buffers are correctly cleaned but if you misuse JOGL, it can create direct NIO buffers at each display, for example when you pass an array instead of passing a direct NIO buffer...
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
I have to correct myself, i delete DirectBuffers not exacltly same as in
https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/util/BufferUtils.java#L1307 I do not use "Method" and ".invoke()" I do it like this: Cleaner cleaner; if(vertices.isDirect()) { ByteBuffer abc = (ByteBuffer)( (DirectBuffer)vertices ).attachment(); cleaner = ((DirectBuffer)abc).cleaner(); if(cleaner != null) { cleaner.clean(); } cleaner = null; abc = null; vertices = null; } Are this two options very different? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Your advice for an plugin for VisualVm is very nice. I didn't know about this plugin before.
With that plugin i can see, that native and java heaps are ok. But program "htop" under ssh says, that my java-process consume more and more RAM memory. Who can consume RAM? |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
This post was updated on Dec 12, 2014; 12:24pm.
As far as I know, a direct NIO byte buffer has no attachment, then abc should be null.
There is a difference between the real Java heap usage, the maximum heap size (see -Xmx) and the current size of the Java heap. I know top and htop but keep in mind that Java uses several kinds of memory. Anyway, you should see something consistent between JVisualVM and htop.
Julien Gouesse | Personal blog | Website
|
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
In reply to this post by Vasilij
On 11/27/2014 03:30 PM, Vasilij [via jogamp] wrote:
> I have to correct myself, i delete DirectBuffers not exacltly same as in > https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/util/BufferUtils.java#L1307 > > I do not use "Method" and ".invoke()" > I do it like this: > > Cleaner cleaner; > if(vertices.isDirect()) > { > ByteBuffer abc = (ByteBuffer)( > (DirectBuffer)vertices ).attachment(); > cleaner = ((DirectBuffer)abc).cleaner(); > > if(cleaner != null) > { > cleaner.clean(); > } > > cleaner = null; > abc = null; > vertices = null; > > } > > Are this two options very different? ... [show rest of quote] ... [show rest of quote] I have also employed sun.misc.Cleaner methods
in GlueGen's MappedByteBufferInputStream: com.jogamp.common.nio.MappedByteBufferInputStream Intent is to use memory mapped NIO files as InputStream and OutputStream while overcoming the NIO buffer 'int' address range. See unit tests: com.jogamp.common.nio.TestByteBufferInputStream com.jogamp.common.nio.TestByteBufferOutputStream com.jogamp.common.nio.TestByteBufferCopyStream Result of using the 'cleaner' depends on the implementing platform, however, 'htop' and other heap monitors show that the mapped memory is released. Hope it helps a bit. ~Sven |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
In reply to this post by Vasilij
Hi all,
here is my Feedback. My Memory Leak is still here, but the cause ist not found. I did not believe that jogl is guilty. If I find the cause, i will tell you what it was. Have a nice day. |
Loading... |
Reply to author |
Edit post |
Move post |
Delete this post |
Delete this post and replies |
Change post date |
Print post |
Permalink |
Raw mail |
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Administrator
|
Hi
Do you create any direct NIO buffers anywhere else in your code or by calling a method of another third party library?
Julien Gouesse | Personal blog | Website
|
Free forum by Nabble | Edit this page |