On 04/07/2008 09:11 AM, "이희승 (Trustin Lee) <[EMAIL PROTECTED]>" wrote:
David M. Lloyd wrote:
On 04/07/2008 02:05 AM, "이희승 (Trustin Lee) <[EMAIL PROTECTED]>" wrote:
We could create a big read buffer and fire a messageReceived event with
its sliced part, but we still have an issue with figuring out what part
of the read buffer is being referenced by user. We can be notified when
the slice is garbage collected using PhantomReference, but its
performance is poor according to my test. Of course, again, we can ask
a user to notify the I/O processor when he or she doesn't need it
anymore, but it's inconvenient and error-prone.
Trustin, what if you only allocate large buffers, and then hand out
slices to it? Rather than using PhantomReferences to track the each
slice, you could track the original buffer itself. Once the original
buffer is no longer referenced, you could then create new slices and
hand them out.
How do you determine if the original buffer is no longer referenced? If
we know that, we can simply reuse the original buffer and that would be
the most efficient implementation.
The same way you already were - with a PhantomReference or similar. I'm
guessing that by having one PhantomReference to many user buffers, maybe
the performance impact won't be so significant.
- DML