2013-01-05 57 views
0

訪問實體列表時,系統會拋出「內存不足」異常。檢索實體框架中的延遲加載列表時出現「內存不足」異常

調用堆棧有一個重複的調用塊,直到應用程序命中內存不足。

調用堆棧:

. 
. 
. 
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) 

在這裏或可能可能是什麼問題任何線索如何去調試問題,一些提示?

,我試圖以模型的層次結構是有點大,有3個級別的繼承:

enter image description here

大約有20個教學班,其從A1衍生,約30類派生哪些來自A2。當我嘗試訪問'A'類型的對象時,系統會'內存不足'。這個問題似乎與EF如何嘗試生成執行計劃和相應的SQL來訪問「A」類型的項目有關。

+2

你應該顯示相應的一段代碼... –

+1

也許你在你的模型中有一些遞歸?如果你添加一些代碼,這將有助於 – MarkG

+0

問題可能是該集合有1億個實體。 – Slauma

回答

0

我能夠解決移動從TPT到TPH的映射問題。我還必須通過重命名具有相同名稱的列來避免EF Code First中的a documented bug

現在我遇到了EF啓動時間跨度小時的問題。我發佈了相同的SO,here

相關問題