strange out-of-memory exception during serialization

前端 未结 4 1357
隐瞒了意图╮
隐瞒了意图╮ 2020-12-17 19:52

I am using VSTS2008 + C# + .Net 3.5 to run this console application on x64 Server 2003 Enterprise with 12G physical memory.

Here is my code, and I find when executin

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-17 20:54

    Interestingly, it actually goes up to 3.7GB before giving a memory error here (Windows 7 x64). Apparently, it would need about double that amount to complete.

    Given that the application uses 1.65GB after creating the table, it seems likely that it's hitting the 2GB byte[] (or any single object) limit Marc Gravell is speaking of (1.65GB + 2GB ~= 3.7GB)

    Based on this blog, I suppose you could allocate your memory using the WINAPI, and write your own MemoryStream implementation using that. That is, if you really wanted to do this. Or write one using more than one array of course :)

提交回复
热议问题