Ivan Volosyuk wrote: > FreeDirect is quite implementable. It is strange that it is not exist > in API. May be it is done this way to be conceptually the same as > ordinary java objects.
I believe the design for NIO buffers is quite nice for the API user -- and leaves the implementers to jump through the hoops, which is arguably the right way around. So as a user I can call: java.nio.ByteBuffer#allocate(int) or java.nio.ByteBuffer#allocateDirect(int) (there is a case that the user should not have to decide between direct or not, but that's how it is) Then in each case the user can discard the Java object to clean up the memory. It is the regular Java object lifecycle in each case, rather than an alloc/free model, and no opportunity for invalid pointer exceptions<g>. In Harmony, ByteBuffer#allocateDirect(int) returns an instance of the concrete package private type called java.nio.DirectByteBuffer, which implements #free(), though of course apps cannot call that method without first casting to the Harmony-specific type. Regards, Tim
