Hi,

Until yesterday I was under the impression that heap buffers are the way to go and direct buffers are more of a relic of at most historical value. This was a belief that was at least partly supported by the Apache MINA project documentation of the upcoming version 2.0. Yesterday my view on heap buffers was completely reversed when I witnessed a perfectly working legacy system (Java 1.4.2 something) barf and die due to lack of direct memory even though we did not explicitly use any direct heap buffers at all. Post mortem heap dumps show that there had been a creation of 100 direct buffers per second and none of them were cleaned since heap memory was fine and no full GC sweep was triggered. The heap contained a chain of 200k cleaners after 30 minutes of uptime. The reason I have not witnessed this before is probably that usually these systems also use a lot of heap memory and therefore trigger full GC which triggers the cleaners.

After a while we realized that in case you use heap buffers, you get a temporary direct buffer. Clearly, at least in this old JVM these temporary direct buffers are not even pooled (that was the WTF of the day!).

This lead me to DIRMINA-391 http://issues.apache.org/jira/browse/DIRMINA-391 . Trustin Lee advocates heap buffers, even though the issue presents a strong case against them. Does this mean that this behavior of using non-pooled temporary direct buffers is a thing of the past, i.e., more modern JVMs are smarter than that? This is the only explanation I can find to why MINA 2.0 uses heap buffers per default and also has dropped the pooling feature of older MINA versions.

The reason I write this mail is that both https://issues.apache.org/jira/browse/DIRMINA-576 and the linked Sun issue seem to contradict this. They both make a strong case for always using pooled direct buffers. What is the community consensus on heap buffers?

Best Regards,
/Dan

Reply via email to