Ok, I looked into possible approaches of implementation garbage-free nio. Let's focus on network communication. For example, for arriving conneciton I have to make an instance of socket (my own implementation) that represents a connection. Socket is an object and it is not so easy to allocate it off-heap (if possible, is it?). Possibilities I see:
1. Just pooling objects.
It is kind of solution but it doesn't seem to be approperiate here.
2. Just treat a socket (and other objects) as simple struct. We can be cunning and allocate chunk of memory with Unsafe.allocateMemory and use it as structs storage. But, in that case JVM is not aware of socket object and it is not pure :]
3. Extend JNI interface and try to allocate natively with malloc (it doesn't seems to be very tricky- I could take pattern from alloc_object (jni.cpp). Obviously, it is not a solution, it is a workaround. (But, so instructive! :) )
What do you think?