windows “系统资源不足...”错误是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2859530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:28:53  来源:igfitidea点击:

What does "Insufficient system resources..." error mean?

javawindowsnioioexceptionfile-copying

提问by Pyrolistical

This question spans both serverfault and stackoverflow so I just picked this one.

这个问题涉及 serverfault 和 stackoverflow,所以我选择了这个。

I get the following exception with some simple file copy code. Its running on Windows Server 2003 x64

我通过一些简单的文件复制代码得到以下异常。它在 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);
    }
}

The thing is the server that is running this code is brand new and super powerful, so I don't understand what system resource it could possibly be running out of.

问题是运行此代码的服务器是全新且超级强大的,所以我不明白它可能耗尽了哪些系统资源。

This looks like the error described here: http://support.microsoft.com/kb/304101

这看起来像这里描述的错误:http: //support.microsoft.com/kb/304101

But I've tried adding the registry edits to increase kernel memory page size, and that didn't help.

但是我尝试添加注册表编辑以增加内核内存页面大小,但这没有帮助。

What I really don't get is I've seen code that uses FileChanneltransferFromwith a lot larger chunks of 50 MB. I've seen that code work for files well over 1 GB in one chunk. But the file the server is getting stuck on is just 32 MB!

我真正不明白的是,我见过使用FileChanneltransferFrom50 MB 大得多的块的代码。我已经看到该代码可以在一个块中处理超过 1 GB 的文件。但是服务器卡住的文件只有 32 MB!

What is going on here? Is this a problem with FileChannelor Windows?

这里发生了什么?这是FileChannelWindows 或 Windows的问题吗?

回答by polygenelubricants

It may be related to "Bug" ID 4938442: Insufficient System Resources When Copying Large Files with NIO FileChannels.

这可能与“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.

评价:不是bug。这很可能是文件服务器(或可能是客户端)配置问题。

客户提交的解决方法:

  • 不要使用蔚来;我们更愿意避免这种解决方法,因为 NIO 为大文件提供了显着的性能提升(至少在执行本地磁盘到本地磁盘复制时)

  • 我们可以使用较少的字节数进行传输。在 Windows XP 和 Windows 2000 服务器上,可复制而不会遇到此错误的实际字节数似乎有所不同。当然,32Mb 的值似乎有效。