title: OutOfMemoryException, I suspect the cause is the DbContext, but I'm not sure?
body: <p>We are having an issue, at some random point in time the application would just throw an outOfMemoryException that I'm unable to consistently reproduce on my local. I have used the Diagnostic Tools in Visual Studio, ANTS Memory Profiler, also created a DUMP file and analized it and everything seems to be pointing at a list of strings created somewhere and not being cleaned by the GC. </p>
  
  <p>When I look at the instances of string in the Diagnostic tools in visual studio it seems that the context is creating more strings and somehow this is linked to the DbContext, I'm not 100% sure why yet. Also when I checked the instances with the ANTS Memory profilers all the strings seemed like Column db names, Db MetaData..etc. </p>
  
  <p><a href="https://i.stack.imgur.com/fYA6Q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fYA6Q.png" alt="enter image description here"></a></p>
  
  <p>Any comment/help/recommendation would be appreciated.</p>
  
  <p><strong>Exception(EDIT):</strong> </p>
  
  <pre><code>                    Exception type: OutOfMemoryException 
                  Exception message: Exception of type 'System.OutOfMemoryException' was thrown.
              at System.Data.SqlClient.TdsParser.TryReadPlpUnicodeChars(Char[]&amp; buff, Int32 offst, Int32 len, TdsParserStateObject stateObj, Int32&amp; totalCharsRead)
              at System.Data.SqlClient.TdsParser.TryReadSqlStringValue(SqlBuffer value, Byte type, Int32 length, Encoding encoding, Boolean isPlp, TdsParserStateObject stateObj)
              at System.Data.SqlClient.TdsParser.TryReadSqlValue(SqlBuffer value, SqlMetaDataPriv md, Int32 length, TdsParserStateObject stateObj, SqlCommandColumnEncryptionSetting columnEncryptionOverride, String columnName)
              at System.Data.SqlClient.SqlDataReader.TryReadColumnData()
              at System.Data.SqlClient.SqlDataReader.TryReadColumnInternal(Int32 i, Boolean readHeaderOnly)
              at System.Data.SqlClient.SqlDataReader.TryReadColumn(Int32 i, Boolean setTimeout, Boolean allowPartiallyReadColumn)
              at System.Data.SqlClient.SqlDataReader.GetString(Int32 i)
              at lambda_method(Closure , Shaper )
              at System.Data.Entity.Core.Common.Internal.Materialization.Coordinator`1.ReadNextElement(Shaper shaper)
              at System.Data.Entity.Core.Common.Internal.Materialization.Shaper`1.SimpleEnumerator.MoveNext()
              at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
              at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
              at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
              at Repositories.AttributeAreaRepository.ActiveAttributesStringForOptions(Int32 builderId, Int32 divisionId, Nullable`1 phasePlanId) in D:\SSSource\Projects\Repositories\AttributeAreaRepository.cs:line 176
              at Web.Areas.Customer.Models.CustomerController.Options(Nullable`1 isSpectOptionTab) in D:\SSSource\Websites\Web\Areas\Customer\Controllers\CustomerController.cs:line 4311
              at Web.Areas.Spec.Controllers.SpecOptionController.Index() in D:\SSSource\Websites\Web\Areas\Spec\Controllers\SpecOptionController.cs:line 35
              at lambda_method(Closure , ControllerBase , Object[] )
              at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
              at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
              at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;BeginInvokeSynchronousActionMethod&gt;b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3d()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.&lt;&gt;c__DisplayClass46.&lt;InvokeActionMethodFilterAsynchronouslyRecursive&gt;b__3f()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass33.&lt;BeginInvokeActionMethodWithFilters&gt;b__32(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass21.&lt;&gt;c__DisplayClass2b.&lt;BeginInvokeAction&gt;b__1c()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.&lt;&gt;c__DisplayClass21.&lt;BeginInvokeAction&gt;b__1e(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
              at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
              at System.Web.Mvc.Controller.&lt;BeginExecuteCore&gt;b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
              at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
              at System.Web.Mvc.Controller.&lt;BeginExecute&gt;b__15(IAsyncResult asyncResult, Controller controller)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
              at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
              at System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult)
              at System.Web.Mvc.MvcHandler.&lt;BeginProcessRequest&gt;b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
              at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
              at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
              at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result)
              at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
              at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
              at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously)
  </code></pre>
  
  <blockquote>
    <p>Blockquote</p>
  </blockquote>