File transfer: Way to much memory being used!
metalstorm
metalheadstorm at gmail.com
Sat Oct 15 22:33:17 EDT 2011
Hi all,
I'm starting a project and testing the waters, I have a simple client and
server and am trying to transfer a file between them, thats all fine, apart
from the server is using way to much memory.
If i send a 1.4GB file, it will use 2.2GB+ of RAM, here's the logic to send
a file.
@Override
public void channelConnected(ChannelHandlerContext ctx, ChannelStateEvent
e) throws IOException
{
Channel ch = e.getChannel();
File myFile = new File("E:\\somewhere\\BigFile.iso");
if (myFile.exists())
{
FileInputStream in = new FileInputStream(myFile);
byte[] buffer = new byte[1024 * 8];
int len = 0;
while ((len = in.read(buffer)) > 0)
{
ch.write(ChannelBuffers.copiedBuffer(buffer));
}
}
}
I've also tried the following buffers: dynamicBuffer, wrappedBuffer,
copiedBuffer. This doesnt happen on the client side when receiving a file.
Any insight ?
Thanks.
--
View this message in context: http://netty-forums-and-mailing-lists.685743.n2.nabble.com/File-transfer-Way-to-much-memory-being-used-tp6896924p6896924.html
Sent from the Netty User Group mailing list archive at Nabble.com.
More information about the netty-users
mailing list