Sunday, April 3, 2011

LINQ to SQL exception: System.OutOfMemoryException

Not sure why I keep getting an OutOfMemory exception. I'm using ASP.NET MVC with LINQ to SQL. Here's some of the stack trace:

[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(IntPtr method) +0
System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType) +7652553
System.Data.Linq.SqlClient.ObjectReaderCompiler.Compile(SqlExpression expression, Type elementType) +442
System.Data.Linq.SqlClient.SqlProvider.GetReaderFactory(SqlNode node, Type elemType) +100
System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query) +253
System.Data.Linq.Table1.System.Linq.IQueryProvider.Execute(Expression expression) +49
System.Linq.Queryable.Single(IQueryable
1 source, Expression`1 predicate) +301
WorkGrabber.Web.Models.WorkGrabberDataContext.GetJob(Int32 id) +233
WorkGrabber.Web.Controllers.BidsController.New(Int32 jobId) +19

From stackoverflow
  • What is your expression? The problem seems to stem from this line:

    System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType) +7652553
    

    That offset seems quite strange. I can hardly believe a normal dynamic method will have a 7.5MB body.

    Franci Penov : From the call stack line, it shows that the error happens while at offset +7652553 from the beginning of the method call.

0 comments:

Post a Comment