File transfer: Way to much memory being used!
Norman Maurer
norman.maurer at googlemail.com
Sun Oct 16 07:16:43 EDT 2011
Use ChunkFile with the ChunkHandler...
Bye
Norman
2011/10/16, metalstorm <metalheadstorm at gmail.com>:
> 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.
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
>
More information about the netty-users
mailing list