Sudden OutOfMemoryExceptions with 2.1.1-runtime-alpine
From @natethegreat44 on June 25, 2018 17:40
Hi,
We have an ASP.NET core app that recently started receiving unexplainable OutOfMemoryExceptions after deployment on Thursday, 21 June, 2018. The exceptions are not usually fatal, but once they start, they grow worse until eventually the dotnet process crashes. Things are usually good for about 18-24 hours after launch, and it doesn't seem to matter much whether things are under load or not - we're using blue/green deployments, and our inactive cluster experiences crashes about as much as the active cluster.
This app serves as an integration layer for other RESTful HTTP services and as such makes extensive use of the HttpClient (i.e. we're not explicitly using any new HTTP Apis from core 2.1).
We're using the standard Alpine Docker images, running on Linux in AWS. Prior to 21 June, we were on 2.1.0 (aka 2.1.300) since 13 June, and 2.0 for quite a while before that, without any OutOfMemoryExceptions. Apparently our build on Thursday was upgraded to 2.1.1 via the 2.1-sdk-alpine and 2.1-runtime-alpine docker base images.
Using tools like ps, htop, it does not appear that memory is actually the cause here - usage typically sits at about 1GB out of 16GB available.
As such, it really looks like something in 2.1.1 is conflicting with our code. An example stack trace is below.
We did manage to capture a few core dumps that we're trying to dig into. In the mean time, if there are a are any other details that might be helpful, please let us know.
Thank you, Nate
[2018-06-24T22:35:24.3939995Z] Level=Error, Category=Whibbidy.Common.Web.HttpHelper, Id=SYSTEM, Message=Error when making web request to GET : Url=https://<redacted>. DoRetry=False. Type=System.Net.Http.HttpRequestException Exception=System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegateInternal(Delegate d)
at Interop.Crypto.X509StoreCtxSetVerifyCallback(SafeX509StoreCtxHandle ctx, X509StoreVerifyCallback callback)
at Internal.Cryptography.Pal.OpenSslX509ChainProcessor.BuildChain(X509Certificate2 leaf, HashSet`1 candidates, HashSet`1 systemTrusted, OidCollection applicationPolicy, OidCollection certificatePolicy, X509RevocationMode revocationMode, X509RevocationFlag revocationFlag, DateTime verificationTime, TimeSpan& remainingDownloadTime)
at Internal.Cryptography.Pal.ChainPal.BuildChain(Boolean useMachineContext, ICertificatePal cert, X509Certificate2Collection extraStore, OidCollection applicationPolicy, OidCollection certificatePolicy, X509RevocationMode revocationMode, X509RevocationFlag revocationFlag, DateTime verificationTime, TimeSpan timeout)
at System.Security.Cryptography.X509Certificates.X509Chain.Build(X509Certificate2 certificate, Boolean throwOnException)
at System.Security.Cryptography.X509Certificates.X509Chain.Build(X509Certificate2 certificate)
at System.Net.Security.CertificateValidation.BuildChainAndVerifyProperties(X509Chain chain, X509Certificate2 remoteCertificate, Boolean checkCertName, String hostName)
at System.Net.Security.SecureChannel.VerifyRemoteCertificate(RemoteCertValidationCallback remoteCertValidationCallback, ProtocolToken& alertToken)
at System.Net.Security.SslState.CompleteHandshake(ProtocolToken& alertToken)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslState.ThrowIfExceptional()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__47_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Whibbidy.Common.Web.HttpHelper.ProcessRequest(String uri, HttpMethod method, HttpHeaders headers, Int32 timeout, String body, String[] redact, Boolean doRetry) in /Whibbidy/src/Whibbidy.Common/Web/HttpHelper.cs:line 259 at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Whibbidy.Common.Web.HttpHelper.ProcessRequest(String uri, HttpMethod method, HttpHeaders headers, Int32 timeout, String body, String[] redact, Boolean doRetry) in /Whibbidy/src/Whibbidy.Common/Web/HttpHelper.cs:line 259
Copied from original issue: dotnet/coreclr#18637
From @stephentoub on June 25, 2018 17:54
An example stack trace is below.
Is it always coming from this same location, or is this just one of many different locations from which you're seeing the OutOfMemoryException?
From @natethegreat44 on June 25, 2018 18:16
Looks like we have it in a couple of different areas related to SSL. All are OutOfMemoryExceptions:
Type=System.Net.Http.HttpRequestException Exception=System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at Interop.Crypto.ErrGetErrorAlloc(Boolean& isAllocFailure)
at Interop.Crypto.CreateOpenSslCryptographicException()
at Interop.OpenSsl.GetSslError(SafeSslHandle context, Int32 result, Exception& innerError)
at Interop.OpenSsl.DoSslHandshake(SafeSslHandle context, Byte[] recvBuf, Int32 recvOffset, Int32 recvCount, Byte[]& sendBuf, Int32& sendCount)
at System.Net.Security.SslStreamPal.HandshakeInternal(SafeFreeCredentials credential, SafeDeleteContext& context, SecurityBuffer inputBuffer, SecurityBuffer outputBuffer, SslAuthenticationOptions sslAuthenticationOptions)
--- End of inner exception stack trace ---
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.BeginAuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions, CancellationToken cancellationToken, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__47_0(SslClientAuthenticationOptions arg1, CancellationToken arg2, AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state)
at System.Net.Security.SslStream.AuthenticateAsClientAsync(SslClientAuthenticationOptions sslClientAuthenticationOptions, CancellationToken cancellationToken)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Whibbidy.Common.Web.HttpHelper.ProcessRequest(String uri, HttpMethod method, HttpHeaders headers, Int32 timeout, String body, String[] redact, Boolean doRetry) in /Whibbidy/src/Whibbidy.Common/Web/HttpHelper.cs:line 259 at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Whibbidy.Common.Web.HttpHelper.ProcessRequest(String uri, HttpMethod method, HttpHeaders headers, Int32 timeout, String body, String[] redact, Boolean doRetry) in /Whibbidy/src/Whibbidy.Common/Web/HttpHelper.cs:line 259
and
Type=System.Net.Http.HttpRequestException Exception=System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.RuntimeTypeHandle.GetGCHandle(RuntimeTypeHandle handle, GCHandleType type)
at System.RuntimeType.get_Cache()
at System.RuntimeType.get_Name()
at System.Resources.ResourceManager..ctor(Type resourceSource)
at System.SR.get_ResourceManager()
at System.SR.GetResourceString(String resourceKey, String defaultString)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.BeginAuthenticateAsClient(SslClientAuthenticationOptions sslClientAuthenticationOptions, CancellationToken cancellationToken, AsyncCallback asyncCallback, Object asyncState)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__47_0(SslClientAuthenticationOptions arg1, CancellationToken arg2, AsyncCallback callback, Object state)
at System.Threading.Tasks.TaskFactory`1.FromAsyncImpl[TArg1,TArg2](Func`5 beginMethod, Func`2 endFunction, Action`1 endAction, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state, TaskCreationOptions creationOptions)
at System.Threading.Tasks.TaskFactory.FromAsync[TArg1,TArg2](Func`5 beginMethod, Action`1 endMethod, TArg1 arg1, TArg2 arg2, Object state)
at System.Net.Security.SslStream.AuthenticateAsClientAsync(SslClientAuthenticationOptions sslClientAuthenticationOptions, CancellationToken cancellationToken)
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Whibbidy.Common.Web.HttpHelper.ProcessRequest(String uri, HttpMethod method, HttpHeaders headers, Int32 timeout, String body, String[] redact, Boolean doRetry) in /Whibbidy/src/Whibbidy.Common/Web/HttpHelper.cs:line 259 at System.Net.Http.ConnectHelper.EstablishSslConnectionAsyncCore(Stream stream, SslClientAuthenticationOptions sslOptions, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Whibbidy.Common.Web.HttpHelper.ProcessRequest(String uri, HttpMethod method, HttpHeaders headers, Int32 timeout, String body, String[] redact, Boolean doRetry) in /Whibbidy/src/Whibbidy.Common/Web/HttpHelper.cs:line 259
and
Type=System.OutOfMemoryException Exception=System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.Net.Http.HttpConnection.HttpContentReadStream.DrainOnDisposeAsync()
at System.Net.Http.HttpConnection.HttpContentReadStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.Net.Http.HttpConnection.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Whibbidy.Common.Web.HttpHelper.ProcessRequest(String uri, HttpMethod method, HttpHeaders headers, Int32 timeout, String body, String[] redact, Boolean doRetry) in /Whibbidy/src/Whibbidy.Common/Web/HttpHelper.cs:line 259 at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
at System.Net.Http.HttpConnection.HttpContentReadStream.DrainOnDisposeAsync()
at System.Net.Http.HttpConnection.HttpContentReadStream.Dispose(Boolean disposing)
at System.IO.Stream.Close()
at System.Net.Http.HttpConnection.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Whibbidy.Common.Web.HttpHelper.ProcessRequest(String uri, HttpMethod method, HttpHeaders headers, Int32 timeout, String body, String[] redact, Boolean doRetry) in /Whibbidy/src/Whibbidy.Common/Web/HttpHelper.cs:line 259
From what I see, they happen in roughly the same quantity.
Using tools like ps, htop, it does not appear that memory is actually the cause here - usage typically sits at about 1GB out of 16GB available.
Is all 16GB actually available to the docker container? This behavior would suggest that the docker container has 1GB limit.
Getting OutOfMemoryException from random places E.g:
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at System.Runtime.CompilerServices.RuntimeHelpers._CompileMethod(IRuntimeMethodInfo method)
at System.Reflection.Emit.DynamicMethod.CreateDelegate(Type delegateType, Object target)
at System.Linq.Expressions.Compiler.LambdaCompiler.CreateDelegate()
at System.Linq.Expressions.Compiler.LambdaCompiler.Compile(LambdaExpression lambda)
at System.Linq.Expressions.Expression`1.Compile(Boolean preferInterpretation)
at MongoDB.Driver.Linq.Translators.FindProjectionTranslator.Translate[TDocument,TProjection](Expression`1 projector, IBsonSerializer`1 parameterSerializer, IBsonSerializerRegistry serializerRegistry)
at MongoDB.Driver.MongoCollectionImpl`1.CreateFindOperation[TProjection](FilterDefinition`1 filter, FindOptions`2 options)
at MongoDB.Driver.MongoCollectionImpl`1.FindAsync[TProjection](IClientSessionHandle session, FilterDefinition`1 filter, FindOptions`2 options, CancellationToken cancellationToken)
at MongoDB.Driver.MongoCollectionImpl`1.UsingImplicitSessionAsync[TResult](Func`2 funcAsync, CancellationToken cancellationToken)
at MongoDB.Driver.IAsyncCursorSourceExtensions.ToListAsync[TDocument](IAsyncCursorSource`1 source, CancellationToken cancellationToken)
at WebApi.Controllers.MyController.Get(Guid id)
one more
System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
at Newtonsoft.Json.JsonPosition.BuildPath(List`1 positions, Nullable`1 currentPosition)
at Newtonsoft.Json.JsonWriter.get_Path()
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
at Mvc.Controllers.HealthcheckController.LogResults(IReadOnlyCollection`1 results)
Docker running alpine image with Asp.Net Core 2.1.1. This started after 2.1.0 to 2.1.1 upgrade.
@pjanotti this is the other issue that may be new with 2.1.1 (but this time not unreadable cert)
@shatl how much memory is the process using at the point it hits OOM? Also, is this Docker and if so how much memory is available?
@jkotas - we are not limiting the docker container memory - it can take what it wants to. We also see it sitting at about 1GB when running in Visual Studio, so that seems to be the natural memory plateau for our app.
@natethegreat44 if 1GB is typical anyway, I assume nothing stands out in the dumps (eg from !dumpheap -stat (info)
It might be worth making a little test console app that allocates much more than 1GB (eg new up some huge arrays) to confirm that the container is not limiting it.
@danmosemsft We run in Docker/AWS. There is a soft limit of 512MB, but at the time of crash application used approx 75MB .
@jkotas if it's using so little memory, what could cause OOM? If it was an attempt at an impossibly large allocation, I think I would expect a consistent callstack?
No idea. There have been multiple similar OOM issues reported against .NET Core 2.1 recently :
https://github.com/dotnet/coreclr/issues/18044 https://github.com/dotnet/coreclr/issues/18577 https://github.com/aspnet/Home/issues/1976 https://github.com/aspnet/EntityFrameworkCore/issues/8223
I suspect there are multiple different root causes that are causing these OOM errors. It is hard to segregate them at this point - we did not really got to the bottom of any of them yet.
@shatl I would try to get a dump file at the point the exception is thrown. There are various ways to do this such as attaching a debugger before the failure. This may help. If you have a Microsoft support contract, product support can help also.
Once that is done we can at least examine the heap.
@mikem8361 could you CreateDump tool help, and if so where are instructions for it?
@pjanotti could you please help drive this one.
https://github.com/dotnet/coreclr/blob/master/Documentation/botr/xplat-minidump-generation.md
@danmosemsft - I added a quick alloc for 1024 * 1024 * 1024 * 2 integers, stored as 1024 int arrays in a List<int[]> and it worked fine. Snapshot from the docker container htop process:

Also, I do have some core dumps from several of the crashes. @eshenem has not been able to open them due to https://github.com/dotnet/coreclr/issues/17850#issuecomment-400109034. Glad to share them with you if you'd like, but will have to go through our corporate channels. @eshenem is also trying to get a core file from a debian instance instead to see if he can open in lldb.
@natethegreat44 can you try the app allocating integers with server vs workstation GC?
@pjanotti - done. Details are below. I noticed that the running instance from my screenshot above did get to VIRT=29.1G, RES=9542M after I let it run (at idle) for a while.

I have similar issues since the upgrade to 2.1.1. I'm using microsoft/dotnet:2.1.1-aspnetcore-runtime-alpine.
And on 4 different microservices.
I'm rolling back to 2.1.
same here, also dotnet:2.1.1-aspnetcore-runtime-alpine
@MichaelSimons Are there any changes in microsoft/dotnet:2.1.1-aspnetcore-runtime-alpine docker image beyond just updating the runtime and aspnet bits? A lot of people are reporting out of memory exceptions when updating to it.
@jkotas, Aside from updating the bits to 2.1.1, the libuv package was also removed from the aspnet image. See https://github.com/dotnet/dotnet-docker/commit/5ebfaacc75058d12fc7d47ad666aee69bbbfe2a7.
Is this possible related to the fix for https://github.com/dotnet/coreclr/issues/17931?