|
[
Permlink
| « Hide
]
Magnus Naeslund added a comment - 23/Jul/05 02:17 AM
Example on solving this, but maybe not the cleanest solution (best might be to not pool it at all)
Maybe i should mention that the patch is totally untested :)
Hi, Magnus.
I agree with current documentation can just let user misuse wrap() methods. But users will still require legacy wrap() methods for performance reason. What do you think about renaming existing wrap methods to 'fastwrap' or something else, and add new wrap() methods that is safer. Any better ideas? Well, the more performant way of doing this would be to have a flag in DefaultByteBuffer that says wether to push the NIO buffer into the stack pool on release().
So when we're using wrap it would still pool the mina bytebuffer container as we do now, but release() would not shove the NIO buffer back into the pool. I whipped up a patch for showing how we could still have performance with wrapped but no memory leaks.
Totally untested, but it compiles :) It is a good idea to specify to pool or not to pool existing NIO buffers and byte arrays internally. I'll try to apply this idea soon, and get back here when done.
I added a property called 'pooled' to MINA ByteBuffer. This property is 'true' by default except for the case you created the wrapped buffer. In case of the wrapped ones, it is 'false' by default so that they are not returned to the buffer pool. Of course you can change this bahavior by calling 'setPooled' method.
I mark this issue as 'resolved' because it resolves all issues addressed here by users who have a concern on it. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||