"内存&QUOT的;除了在检索懒加载列表中的实体框架 [英] "Out of Memory" exception while retrieving a lazy-loaded list in Entity Framework

查看:132
本文介绍了"内存&QUOT的;除了在检索懒加载列表中的实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当访问实体的列表,系统将引发内存出异常。

While accessing a list of entity, the system throws an "Out of Memory" exception.

调用堆栈有呼叫的块,重复,直到应用程序出击的记忆。

The call stack has a block of calls which repeats till the application hits out of memory.

调用堆栈:

.
.
.
at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
/* Repeating Block */
at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitChildren(Node n)
at System.Data.Query.PlanCompiler.JoinElimination.VisitDefaultForAllNodes(Node n)
at System.Data.Query.PlanCompiler.JoinElimination.VisitDefault(Node n)
at System.Data.Query.InternalTrees.BasicOpVisitorOfNode.VisitPhysicalOpDefault(PhysicalOp op, Node n)
at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.Visit(PhysicalProjectOp op, Node n)
at System.Data.Query.InternalTrees.PhysicalProjectOp.Accept[TResultType](BasicOpVisitorOfT`1 v, Node n)
at System.Data.Query.InternalTrees.BasicOpVisitorOfT`1.VisitNode(Node n)
/* Repeating Block */
at System.Data.Query.PlanCompiler.JoinElimination.Process()
at System.Data.Query.PlanCompiler.PlanCompiler.Compile(List`1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set`1& entitySets)
at System.Data.Query.PlanCompiler.PlanCompiler.Compile(DbCommandTree ctree, List`1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set`1& entitySets)
at System.Data.EntityClient.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
at System.Data.EntityClient.EntityProviderServices.CreateCommandDefinition(DbProviderFactory storeProviderFactory, DbCommandTree commandTree)
at System.Data.EntityClient.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
at System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Span span, ReadOnlyCollection`1 compiledQueryParameters, AliasGenerator aliasGenerator)
at System.Data.Objects.EntitySqlQueryState.GetExecutionPlan(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.Execute(MergeOption mergeOption)
at System.Data.Objects.DataClasses.EntityCollection`1.Load(List`1 collection, MergeOption mergeOption)
at System.Data.Objects.DataClasses.EntityCollection`1.Load(MergeOption mergeOption)
at System.Data.Objects.DataClasses.RelatedEnd.Load()
at System.Data.Objects.DataClasses.RelatedEnd.DeferredLoad()
at System.Data.Objects.Internal.LazyLoadBehavior.LoadProperty[TItem](TItem propertyValue, String relationshipName, String targetRoleName, Boolean mustBeNull, Object wrapperObject)
at System.Data.Objects.Internal.LazyLoadBehavior.<>c__DisplayClass7`2.<GetInterceptorDelegate>b__1(TProxy proxy, TItem item)

这是什么可能是这里的问题或任何线索可能就如何去调试问题的一些提示吗?

Any clue on what might be the issue here or probably some hints on how to go about debugging the issue?

这是我想要的模型的层次是有点大,有3个级别的继承:

The hierarchy that I'm trying to model is a little big, with 3 levels of inheritance:

有它们是从A 1派生约30班从A2的哪派生约20类和。该系统变为内存不足当我试图访问类型A的对象。这个问题似乎是与EF如何尝试生成执行计划和相应的SQL来访问'A'型的项目。

There are around 20 classes which are derived from A1, and about 30 classes which derive from A2. The system goes 'Out of Memory' when I try to access an object of type 'A'. The issue seems to be with how the EF tries to generate execution plans and corresponding SQL to access an item of type 'A'.

推荐答案

我能够与移动映射从TPT到TPH解决这个问题。我也必须避免在EF code进行记录错误首先通过重命名列具有相同的名称。

I was able to fix the issue with moving the mapping from TPT to TPH. I also had to avoid a documented bug in EF Code First by renaming columns with same name.

现在我被困在某个问题上与英法的启动时间是跨越小时。我已经发布了同样的SO,​​<一个href="http://stackoverflow.com/questions/14315425/entity-framework-taking-a-lot-of-time-initializing-model">here.

Now I'm stuck on an issue with EF start up time which is spanning hours. I have posted the same at SO, here.

这篇关于&QUOT;内存&QUOT的;除了在检索懒加载列表中的实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆