the cleaner is supposed to be called by the finalizer/gc, not really by hand. GC is issued every time you create a new directbuffer without having enough “free” memory available. that’s the last call for the cleaner if it didn’t run already. if you dont want to use reflections then, don’t use it. everything should still work and hopefully not cause too many memleaks. why not just use icode.cleaner().clean()[/icode] ?
i guess if deallocation is really an issue then using directbuffers is the wrong idea in the first place. in that case any un-smart way to release is fine
one workaround which works for me is using [icode]Unsafe.allocateMemory[/icode] + [icode]Unsafe.freeMemory[/icode] and the private [icode]DirectByteBuffer(long addr, int cap, Object ob)[/icode] constructor, which also sets the cleaner to null. that way it’s possible to bypass [icode]Bits.reserveMemory(long size, int cap)[/icode] which is absolutely useles unless you plan compatibility to heap-buffers. you end up with reflections again tho’.