none
OutofMemory Exception in Entity Framework RRS feed

  • Question

  • Hi,

    Please see below stack trace of exception. It is throwing Outof memory exception on an linq to sql query  whereas query is not able to produce more than 65 Records.

    Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Data.Query.PlanCompiler.PropertyPushdownHelper.GetPropertyRefList(Node node) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.VisitPropertyOp(Op op, Node n, PropertyRef propertyRef) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(PropertyOp op, Node n) at System.Data.Query.InternalTrees.PropertyOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.VisitDefault(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitScalarOpDefault(ScalarOp op, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.Visit(NewEntityOp op, Node n) at System.Data.Query.InternalTrees.NewEntityOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(VarDefOp op, Node n) at System.Data.Query.InternalTrees.VarDefOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(VarDefListOp op, Node n) at System.Data.Query.InternalTrees.VarDefListOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ScanViewOp op, Node n) at System.Data.Query.InternalTrees.ScanViewOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.VisitJoinOp(JoinBaseOp op, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.Visit(InnerJoinOp op, Node n) at System.Data.Query.InternalTrees.InnerJoinOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(FilterOp op, Node n) at System.Data.Query.InternalTrees.FilterOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(PhysicalProjectOp op, Node n) at System.Data.Query.InternalTrees.PhysicalProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Process(Command itree, StructuredTypeInfo structuredTypeInfo, Dictionary`2& varPropertyRefs, Dictionary`2& nodePropertyRefs) at System.Data.Query.PlanCompiler.NominalTypeEliminator.Process(PlanCompiler compilerState, StructuredTypeInfo structuredTypeInfo) at System.Data.Query.PlanCompiler.PlanCompiler.Compile(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) at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at

    • Moved by CoolDadTx Monday, June 24, 2013 1:56 PM EF related
    Monday, June 24, 2013 9:17 AM

Answers

  • See here regarding debugging out of Memory Excpetion. Especialyl regarding the 2 GiB Limit:

    http://blogs.iis.net/webtopics/archive/2009/05/22/troubleshooting-system-outofmemoryexceptions-in-asp-net.aspx

    The usual causes with DB access are:
    1. You retrieve too much. Either values you do not need, or with too little filtering. Also, your datatypes might be wrong (retreivign strings or large blobs). Consider using paging.
    2. Something else takes up a lot of memory.

    For a short time DB access will need twice the normal memory amount - once in the resultset it get's from the server. And then for the datastructure to persistently store it in (resultset loose ther validity when the connection is closed).


    Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2

    Monday, June 24, 2013 1:44 PM

All replies

  • Hi,

    you will get better responses by posting this question in this forum: http://social.msdn.microsoft.com/Forums/en-US/home?forum=adodotnetentityframework . You also should provide the code which is throwing the Out of memory exception.


    Hannes

    If you have got questions about this, just ask.

    In a perfect world,
    users would never enter data in the wrong form,
    files they choose to open would always exist
    and code would never have bugs.

    My Forum Threads

    Monday, June 24, 2013 9:23 AM
  • Hi,

    Please see below stack trace of exception. It is throwing Outof memory exception on an linq to sql query  whereas query is not able to produce more than 65 Records.

    Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at System.Data.Query.PlanCompiler.PropertyPushdownHelper.GetPropertyRefList(Node node) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.VisitPropertyOp(Op op, Node n, PropertyRef propertyRef) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(PropertyOp op, Node n) at System.Data.Query.InternalTrees.PropertyOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.VisitDefault(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitScalarOpDefault(ScalarOp op, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.Visit(NewEntityOp op, Node n) at System.Data.Query.InternalTrees.NewEntityOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(VarDefOp op, Node n) at System.Data.Query.InternalTrees.VarDefOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(VarDefListOp op, Node n) at System.Data.Query.InternalTrees.VarDefListOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ScanViewOp op, Node n) at System.Data.Query.InternalTrees.ScanViewOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.VisitJoinOp(JoinBaseOp op, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.Visit(InnerJoinOp op, Node n) at System.Data.Query.InternalTrees.InnerJoinOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(FilterOp op, Node n) at System.Data.Query.InternalTrees.FilterOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(ProjectOp op, Node n) at System.Data.Query.InternalTrees.ProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitNode(Node n) at System.Data.Query.InternalTrees.BasicOpVisitor.VisitChildren(Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Visit(PhysicalProjectOp op, Node n) at System.Data.Query.InternalTrees.PhysicalProjectOp.Accept(BasicOpVisitor v, Node n) at System.Data.Query.PlanCompiler.PropertyPushdownHelper.Process(Command itree, StructuredTypeInfo structuredTypeInfo, Dictionary`2& varPropertyRefs, Dictionary`2& nodePropertyRefs) at System.Data.Query.PlanCompiler.NominalTypeEliminator.Process(PlanCompiler compilerState, StructuredTypeInfo structuredTypeInfo) at System.Data.Query.PlanCompiler.PlanCompiler.Compile(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) at System.Data.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption) at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at

    Monday, June 24, 2013 9:29 AM
  • See here regarding debugging out of Memory Excpetion. Especialyl regarding the 2 GiB Limit:

    http://blogs.iis.net/webtopics/archive/2009/05/22/troubleshooting-system-outofmemoryexceptions-in-asp-net.aspx

    The usual causes with DB access are:
    1. You retrieve too much. Either values you do not need, or with too little filtering. Also, your datatypes might be wrong (retreivign strings or large blobs). Consider using paging.
    2. Something else takes up a lot of memory.

    For a short time DB access will need twice the normal memory amount - once in the resultset it get's from the server. And then for the datastructure to persistently store it in (resultset loose ther validity when the connection is closed).


    Let's talk about MVVM: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/b1a8bf14-4acd-4d77-9df8-bdb95b02dbe2

    Monday, June 24, 2013 1:44 PM