内存不足异常。 C#

时间:2015-09-22 06:58:33

标签: c# visual-studio-2008 compact-framework windows-mobile-6.5

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream respStream = response.GetResponseStream();
using (var sr = new StreamReader(respStream, Encoding.UTF8))
using (JsonReader reader = new JsonTextReader(sr))
 {
    JsonSerializer serializer = new JsonSerializer();
    ServiceModel toReturn = serializer.Deserialize<ServiceModel>(reader);
    String resps = JsonConvert.SerializeObject(toReturn, Formatting.Indented);
  }

在此行之后获取OutOfMemory异常:

String resps = JsonConvert.SerializeObject(toReturn, Formatting.Indented);

如何在C#(Compact Framework)中处理它。

1 个答案:

答案 0 :(得分:0)

看起来有一些循环引用...使用http://www.ndepend.com/Features/#DependencyCycle来检查