.net - MemoryStream 使用了多少内存?

标签 .net memorystream

我有一台 2 GB 的机器。在运行我的 exe 之前,我有 1.1 GB 的可用内存。当我运行下面只有一行的 exe 时,出现内存不足异常。

我预计以下行将使用大约 6 亿字节。 MemoryStream 类使用的内存是否多于初始化容量?

MemoryStream memory = new MemoryStream(600000000);

最佳答案

根据以下问答,很可能是因为您的EXE无法分配600兆的连续内存。 (我试图在文档中找到一些东西,这是我在短时间内能想到的最好的东西。)

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/1af59645-cdef-46a9-9eb1-616661babf90

"An “out of memory” error almost never happens because there’s not enough storage available; as we’ve seen, storage is disk space, and disks are huge these days. Rather, an “out of memory” error happens because the process is unable to find a large enough section of contiguous unused pages in its virtual address space to do the requested mapping."

有趣的是,该答案链接到 Eric Lippert's博客文章: http://blogs.msdn.com/b/ericlippert/archive/2009/06/08/out-of-memory-does-not-refer-to-physical-memory.aspx

关于.net - MemoryStream 使用了多少内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13385452/

相关文章:

c# - GeckoFX WebBrowser 页面高度和宽度

c# - MemoryStream输出到文件c#

linq - 使用 LinqToCSV 将 CSV 写入 MemoryStream 不会返回任何数据

c# - 将位图保存到内存流时可以将位图转换为 jpeg 吗?

c# - Ziparchive:如何从 ziparchive 关闭创建的条目

c# - sql查询中的多个SELECT命令

c# - 多线程求和给出不正确的结果

c# - 从内存流读取时的 Naudio 和 Syn 语音空引用错误

c# - 使用 Web 服务时出现 SocketException

c# - 如何在richTextBox的索引0中的每一行附近添加数字?