标签:file-copying ioexception nio windows java
这个问题涉及到服务器故障和堆栈溢出,因此我只选择了一个.
我得到了一些简单的文件复制代码的以下异常.它运行在Windows Server 2003 x64上
Caused by: java.io.IOException: Insufficient system resources exist to complete the requested service
at sun.nio.ch.FileDispatcher.pwrite0(Native Method)
at sun.nio.ch.FileDispatcher.pwrite(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.FileChannelImpl.write(Unknown Source)
at sun.nio.ch.FileChannelImpl.transferFromFileChannel(Unknown Source)
at sun.nio.ch.FileChannelImpl.transferFrom(Unknown Source)
at Tools.copy(Tools.java:473)
public static void copy(FileChannel input, FileChannel output) throws IOException {
final long size = input.size();
long pos = 0;
while (pos < size) {
final long count = (size - pos) > FIFTY_MB ? FIFTY_MB : (size - pos);
pos += output.transferFrom(input, pos, count);
}
}
问题是运行此代码的服务器是全新的且功能强大,因此我不知道它可能耗尽了哪些系统资源.
这看起来像这里描述的错误:
http://support.microsoft.com/kb/304101
但是我尝试添加注册表编辑来增加内核内存页面大小,但这没有帮助.
我真正不明白的是,我已经看到了使用FileChannel transferFrom的代码,其中包含了更大的50 MB块.我已经看到代码可以在一个大块中处理超过1 GB的文件.但是服务器卡住的文件只有32 MB!
这里发生了什么?这是FileChannel或Windows的问题吗?
解决方法:
它可能与“Bug” ID 4938442: Insufficient System Resources When Copying Large Files with NIO FileChannels有关.
Evaluation: Not a bug. This is most likely a file-server (or possibly client)
configuration issue.CUSTOMER SUBMITTED WORKAROUND :
Don’t use NIO; we’d prefer to avoid this workaround since
NIO offers a significant performance boost for large files
(at least when performing local disk-to-local disk copies)We can transfer using a smaller number of bytes. The
actual number of bytes that may be copied without
encountering this error seems to differ on Windows XP and
Windows 2000 server. Certainly a value of 32Mb appears to
work.
标签:file-copying,ioexception,nio,windows,java 来源: https://codeday.me/bug/20191106/1999880.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。