Getting an OutOfMemoryException while serialising to JSON?(序列化为 JSON 时出现 OutOfMemoryException?)
问题描述
我正在序列化,一个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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:序列化为 JSON 时出现 OutOfMemoryException?
基础教程推荐
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- rabbitmq 的 REST API 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何激活MC67中的红灯 2022-01-01