directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Niklas Therning <>
Subject Re: [MINA] OutOfMemoryError on streaming large files
Date Tue, 13 Dec 2005 05:42:59 GMT
Trustin Lee wrote:
> 2005/12/12, Niklas Therning <
> <>>:
>     If my theory is correct the remedy would be to remove the while-loop and
>     instead add the InputStream you're reading from as a session attribute.
>     Then override messageSent() in your IoFilter and each time it gets
>     called you write the next 4K of data from the InputStream. This way you
>     write data in chunks of 4K and you only send the next 4K once the
>     previous 4K has been sent.
>     Once all the data from the InputStream has been written you forward the
>     messageSent() call to the IoHandler with the original InputStream as
>     message.
>     If you try this out and it works I think we could add this filter to
>     MINA if you are willing to share it.
> My suggestion is easy to code, but it will make you to waste some
> threads.  Please try mine first and then try Niklas's suggestion.  His
> solution is also correct, and more efficient.

Thanks Trustin, I didn't think of that. Johannes, you should definitely
try Trustin's suggestion first and see if that gets rid of the memory
problem. It basically does what I suggested and is a whole lot simpler
to try out but it will waste precious threads.


View raw message