On Thu, 22 May 2008 05:14:24 +0900, Emmanuel Lecharny <[EMAIL PROTECTED]> wrote:

Rich Dougherty wrote:
Hi Daniel

Although MINA probably *uses* buffers for short periods of time, wouldn't it
be possible to make the underlying buffers "long-lived" by pooling them
between usages? Of course, if we pooled buffers then we'd need to support some mechanism of returning the buffers to the pool (probably an explicit *
free* or *dispose* operation).


Pooling objects instead of simple let the GC dispose them is not a good strategy with modern JVM. With a pool, you introduce a synchronized structure which will cost more to manage than letting the JVM creating new objects.

I have played this game years ago, and when switching to Java 5, and even Java 1.4 to a certain extent, found it a waste of time and energy ...

Allocating a big direct buffer (say 16MB) once and slicing it into many pieces for allocation showed very nice performance. The problem is that the current JVM implementation is not good at handling many big direct buffer allocations - they are not freed when we need it to be freed. Tomcat native provides a way to explicitly free direct buffers, so it might resolve the issue.

Anyway, I think we can implement ByteBufferQueue work with both heap and direct buffers and then think about the side effect of using direct buffers and discuss what would be the solution?

Seems like we all like the proposed interface anyway.  Cool!

Thanks,
--
Trustin Lee - Principal Software Engineer, JBoss, Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/

Reply via email to