【问题标题】:DataContractSerializer leaking memory until process dieDataContractSerializer 泄漏内存直到进程终止
【发布时间】:2010-01-05 18:57:02
【问题描述】:

我有一个使用 EF4 的 .net4 应用程序,我使用 BasicHttpBinding 通过 WCF 公开我的模型(但这可以更改),每次我尝试调用此方法时,我的 Web 服务器进程开始在内存中增长并且进程死亡。

问题是当 DataContractSeralizer 试图序列化我的实体(有一些关系)进入递归堆栈时。那么,为了通过 WCF 服务此实体,是否有任何特殊配置或我缺少的东西。

这里有一些额外的信息: 我的 EF 模型截图:http://www.luisguerrero.net/stackoverflow/efmodel.jpg

public List<ExtendedSession> GetAllExtendedSessionByFilter(int id)
{
        QueryDataAccess<ExtendedSession, NextWebEntities> query = new QueryDataAccess<ExtendedSession, NextWebEntities>("ExtendedSession");
        List<ExtendedSession> result = query.GetAllByFilter(item => item.SessionId == id, "Rule");
        return result;
}

【问题讨论】:

    标签: .net wcf entity-framework memory-leaks datacontractserializer


    【解决方案1】:

    我通常通过序列化没有任何循环引用的数据投影来解决这个问题,编写为 LINQ 查询。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-27
      • 2018-11-12
      • 2021-09-01
      • 2019-02-17
      • 2017-12-21
      • 2018-09-11
      • 2014-05-02
      相关资源
      最近更新 更多