What's holding up my ByteBuffer from freeing?

You can use a tool like MAT that's free with Eclipse to see what is keeping your byte buffer by letting it do some heapdump analysis.

You can use a tool like MAT that's free with Eclipse to see what is keeping your byte buffer by letting it do some heapdump analysis. Another way I can think of is to wrap your byte buffer with something else that has a finalizer method. Also Systen.gc() does not guarantee that finalizers will be executed you need to do System.runFinalization() to increase the likelihood.

You can get MAT at eclipse.org/mat – Ted Hopp Oct 31 '11 at 3:43.

Setting the references to null is the correct way to let the garbage collector that you are finished with that object. There must still be some other dangling reference. The best tool I have found for finding memory leaks is YourKit.

A free alternative that is also very good is Visual VM from the JDK. Remember that the slice() operation creates a new byte buffer that references the first one.

This is a problem with older versions of Java. The latest version of Java 6 will call System.gc() before throwing an OutOfMemoryError. If you don't want to trigger a GC you can release the direct memory manually on the Oracle/Sun JVM with ((DirectBuffer) buffer).cleaner().clean(); However, it is a better approach to recycle the direct buffers yourself so doing this is not so critical.(Creating direct ByteBuffers is relatively expensive).

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions