question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OutOfMemoryException on V3 to V4 Migration (with .NET Core 3.1 to .NET 6.0)

See original GitHub issue

I migrated an existing .NET Core 3.1 in-proc Azure Functions app to .NET 6.0 using the guidance at https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=in-process%2Cv4&pivots=programming-language-csharp#migrating-from-3x-to-4x. Then I published (with setting delete all extra files) to the slot where the .NET Core 3.1 function lived and worked nicely for months.

The code in question opens read to Blob storage (custom code, no trigger). Simplified:

var client = new BlobServiceClient(new Uri($"https://{_accountName}.blob.core.windows.net"), _accountCredentials);
var blobClient = client.GetBlobContainerClient(containerName).GetBlobClient(blobName);

var stream = await blobClient.OpenReadAsync(new BlobOpenReadOptions(false));

This then OOMs.

Investigative information

  • Windows consumption tier
  • Timestamp: 2021-11-23 10:07:17.691
  • Function App version: 4.0.1.16815
  • Function App name: eeazfuncppe
  • Function name(s) (as appropriate): ReadRevitVersion

| where operation_Id == ‘2c0db5f3218278cae72bf3ae9bdeced7’ | where customDimensions[‘InvocationId’] == ‘6299cbff-aaa3-4d2b-8bfe-9184dcede4ca’

Exception:

System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.GC.AllocateNewArray(IntPtr typeHandle, Int32 length, GC_ALLOC_FLAGS flags)
   at System.Buffers.TlsOverPerCoreLockedStacksArrayPool`1.Rent(Int32 minimumLength)
   at Azure.Storage.Blobs.Specialized.BlobBaseClient.OpenReadInternal(Int64 position, Nullable`1 bufferSize, BlobRequestConditions conditions, Boolean allowModifications, Boolean async, CancellationToken cancellationToken)
   at Azure.Storage.Blobs.Specialized.BlobBaseClient.OpenReadAsync(BlobOpenReadOptions options, CancellationToken cancellationToken)
   at MyFunc.ReadRevitVersionFunc.Run(HttpRequest req, ILogger log) in D:\VIMaecWorkspace\Repos\estimatingedge\src\MyFunc\ReadRevitVersionFunc.cs:line 37

Side-note: I am having problems with OOM on Windows Docker Container for .NET 6.0 too (totally different though), so maybe that is related here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
pragnagopacommented, Nov 23, 2021

Thanks @christophwille for sharing the details!. There is a known issue in the platform for x64 bit Function Apps running on Windows in dynamic sku. Fix will be rolled out in the next couple of months. Until then please set App Setting: COMPLUS_GCHeapHardLimit to the value 0x60000000

cc @fabiocav @kranthikumarm @safihamid

1reaction
fdipumacommented, Nov 30, 2021

We are experiencing the same issue after migrating an app from .NET Core 3.1 + Functions v3 to .NET 6 + Functions v4.

64bit app config.

Is that related to https://github.com/Azure/azure-functions-host/issues/5430 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Migrate from ASP.NET Core 3.1 to 6.0
Learn how to migrate an ASP.NET Core 3.1 project to ASP.NET Core 6.0.
Read more >
EF add-migration throwing System.OutOfMemoryException
When I try to add a migration file through PM I get an out of memory exception. Anyone else had this problem before...
Read more >
Migration From .NET Core 3.1 To .NET 6
This article describes how to upgrade the solution from .NET Core 3.1 to .NET 6.0 with an example of a web application project....
Read more >
Find, Fix, and Avoid Memory Leaks in C# .NET: 8 Best ...
The first core cause is when you have objects that are still referenced ... .NET itself has a lot of classes that allocate...
Read more >
How to Easily Migrate Your ASP.NET Core 3.1 ... - YouTube
This video on migration to ASP. NET 6.0 from ASP. NET Core 3.1 is my Christmas present to my community. It explains how...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found