runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Multiple 'System.OutOfMemoryException' errors in .NET 7

Open theolivenbaum opened this issue 4 years ago • 71 comments

I'm seeing an issue very similar to this one when running a memory-heavy app on a linux container with memory limit >128GB RAM.

The app started throwing random OutOfMemoryException in many unexpected places since we migrated to net70, while under no memory pressure (usually with more than 30% free memory).

I can see the original issue was closed, but I'm not sure if it was fixed on the final net70 release or if the suggestion to set COMPlus_GCRegionRange=10700000000 is the expected workaround.

theolivenbaum avatar Nov 29 '22 09:11 theolivenbaum

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

ghost avatar Nov 29 '22 09:11 ghost

Tagging subscribers to this area: @dotnet/gc See info in area-owners.md if you want to be subscribed.

Issue Details

I'm seeing an issue very similar to this one when running a memory-heavy app on a linux container with memory limit >128GB RAM.

The app started throwing random OutOfMemoryException in many unexpected places since we migrated to net70, while under no memory pressure (usually with more than 30% free memory).

I can see the original issue was closed, but I'm not sure if it was fixed on the final net70 release or if the suggestion to set COMPlus_GCRegionRange=10700000000 is the expected workaround.

Author: theolivenbaum
Assignees: -
Labels:

area-GC-coreclr, untriaged

Milestone: -

ghost avatar Nov 29 '22 14:11 ghost

Thanks for reporting this issue. This looks like its separate than the original issue -- we are investigating something similar with another customer. Would it be possible to share a dump when the OOM happens?

mangod9 avatar Nov 29 '22 15:11 mangod9

Unfortunately not as this is running within a customer infrastructure and the dump would most probably contain confidential data. Is there an issue here on GitHub I can subscribe to?

theolivenbaum avatar Nov 29 '22 16:11 theolivenbaum

We dont have an issue yet, so will use this to provide updates. Its most likely something which is fixed in main which might need porting to 7: https://github.com/dotnet/runtime/pull/77478

mangod9 avatar Nov 29 '22 16:11 mangod9

Hi @theolivenbaum, would it be possible for you to try out a private to ensure the fix resolves your issue?

Thanks

mangod9 avatar Nov 29 '22 18:11 mangod9

That might be hard as it would involve changing how we build our docker images. But fine to wait till this is back ported to 7 - any idea on a timeline for the next service release?

theolivenbaum avatar Nov 29 '22 18:11 theolivenbaum

We're also seeing a lot of OOM exceptions since migrating to .NET 7 from .NET 5 (we're now testing .NET 6). In our case, we're running under Windows via Azure App Services. Reported memory usage is low - perhaps lower than what it was under .NET 5. The project in question loads large-ish files in memory.

Quppa avatar Dec 01 '22 22:12 Quppa

can you try if setting COMPlus_GCName=clrgc.dll or COMPlus_GCName=libclrgc.so make the OOMs go away? We are working on a fix, but hoping this could be a temporary workaround. Thx.

mangod9 avatar Dec 01 '22 22:12 mangod9

We'll try to find time to test this.

Quppa avatar Dec 01 '22 23:12 Quppa

@mangod9 We're seeing a similar issue with .NET7 on Ubuntu loading larger files (10+ MB) with File.ReadAllBytes. This works fine on .NET6

Setting COMPlus_GCName=libclrgc.so resolves the issue for our setup with .NET7

jeremyosterhoudt avatar Dec 02 '22 03:12 jeremyosterhoudt

it'd be helpful to see what !ao displays (it's an sos extension). would that be possible? that's always the 1st step if you have a dump.

Maoni0 avatar Dec 02 '22 03:12 Maoni0

Setting COMPlus_GCName=libclrgc.so resolves the issue for our setup with .NET7

ok good to know, yeah like Maoni suggests getting a dump or trace can help confirm whether its the same issue. We hope to get it fixed in an upcoming servicing release.

mangod9 avatar Dec 02 '22 04:12 mangod9

Hopefully I did this right. I followed this guild. Here is the output:

---------Heap 1 ---------
Managed OOM occurred after GC #4 (Requested to allocate 6028264 bytes)
Reason: Could not do a full GC

jeremyosterhoudt avatar Dec 02 '22 06:12 jeremyosterhoudt

thanks, it does look similar to other cases we have seen.

mangod9 avatar Dec 02 '22 16:12 mangod9

would it be possible to try out a private fix? we could deliver a libclrgc.so to you and you could use it the same way you used the shipped version. that would be really helpful.

Maoni0 avatar Dec 05 '22 05:12 Maoni0

That would probably be possible! Also while we're at it, is there any recommendation on how to get memory dumps from within a container?

theolivenbaum avatar Dec 05 '22 06:12 theolivenbaum

I have copied a private libcoreclr.so at https://1drv.ms/u/s!AtaveiZOervriJhkWC64gVEV8dAHug?e=IyBaP3, if you want to give that a try. You will want to remove the COMPlus_GCName config.

mangod9 avatar Dec 05 '22 07:12 mangod9

@mangod9 @Maoni0 just got the chance to test today the library you sent, and after a day of usage under load no issues so far!

theolivenbaum avatar Dec 06 '22 18:12 theolivenbaum

ok thanks for trying it out. We will do additional validation and add it to a .NET 7 servicing release (due to holidays might be in Feb).

mangod9 avatar Dec 06 '22 20:12 mangod9