编程语言
首页 > 编程语言> > java-“系统资源不足…”错误是什么意思?

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