FileChannel.transferTo fails with large files

Alan Bateman Alan.Bateman at Sun.COM
Thu Mar 5 03:18:01 PST 2009


Mark Thornton wrote:
> Operating system: Vista 32 bit
> JVM 1.6 u10
> Heap size 1200MB
> File size ~ 1GB
>
> It appears to work by memory mapping the file in one piece which not 
> surprisingly fails in these circumstances (large file, large heap, 32 
> bit process). The resulting OutOfMemoryError is not what I would 
> expect from reading the method documentation.
>
> Should this implementation be reconsidered?
>
> Mark Thornton
Yes, this does needs to be re-examined. It's usually not a problem on 
Solaris/Linux because the target channel is typically a SocketChannel 
and so sendfile is used. The equivalent of sendfile on Windows is 
TransmitFile but it doesn't have the required semantics so we can't use 
this. This means on Windows we will always go for memory mapping when 
the target is a file or selectable channel. The bug for this is 6431344.

-Alan.




More information about the nio-dev mailing list