strange out-of-memory exception during serialization

前端 未结 4 1381
隐瞒了意图╮
隐瞒了意图╮ 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:34

    Note: DataTable defaults to the xml serialization format that was used in 1.*, which is incredibly inefficient. One thing to try is switching to the newer format:

     dt.RemotingFormat = System.Data.SerializationFormat.Binary;
    

    Re the out-of-memory / 2GB; individual .NET objects (such as the byte[] behind a MemoryStream) are limited to 2GB. Perhaps try writing to a FileStream instead?

    (edit: nope: tried that, still errors)

    I also wonder if you may get better results (in this case) using table.WriteXml(stream), perhaps with compression such as GZIP if space is a premium.

提交回复
热议问题