我正在序列化,一个MultiDictionary<String,Object>
http://powercollections.codeplex.com/到 json .
它有 618 个元素,元素被深度嵌套,即单个对象中可能有几个类似字典的对象.我正在使用 JSON.Net
It has 618 elements with elements being deeply nested ,i.e. a single Object may have several dictionary like objects in it . I am using JSON.Net
String json = JsonConvert.SerializeObject(json, Newtonsoft.Json.Formatting.Indented);
我错过了什么?
更多信息:-这在我使用动态之前工作正常,我不得不切换到 MultiDictionary 以允许多个同名属性.它适用于大多数情况,只有当项目数量很大时才会中断.
MORE INFO: - This was working fine till i was using dynamic , i had to switch to MultiDictionary to allow multiple properties of the same name . It works for most cases , only when the number of items is large , it breaks .
更新:-
我已经能够控制内存消耗,但减少了一些递归添加到每个元素的元素.
I have been able to get a hold of the Memory consumption but cutting down on some elements that were getting added recursively to each element.
您似乎遇到了 Ciruclar Reference 导致 OutOfMemoryException
或您的对象对您的内存来说太大了.使用 NDepend 进行检查.
It appears that you're running into Ciruclar Reference that is causing OutOfMemoryException
or your objects are simply too large for your memory. Use NDepend to check this.
您可能会发现获取对象的总大小很有用一个>.
这篇关于序列化为 JSON 时出现 OutOfMemoryException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!