Replies: 1 comment 10 replies
-
cc @mangod9 |
Beta Was this translation helpful? Give feedback.
10 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This question ties to this post:
#47659
which references this partial fix:
https://docs.microsoft.com/en-us/dotnet/core/runtime-config/garbage-collector#heap-limit-percent
But leaves much to be desired, as the result is tedious/non-elegant code to ensure you never get an OOM (or ASP restart when memory exceeds a limit).
What I would suggest is that you add a GC setting like this:
AutoCompactLargeObjectHeapOnOutOfMemoryException = true
If 'true', then when an OutOfMemory exception occurs (OOM), it would do a GC2 and Compact the LOH, and then would RETRY the allocation that failed!
How useful would this be?!?!? We can have 1000's of places in our code that might make the "final allocation that causes the OOM" - and we don't want to have 1000 mechanisms for "try allocation, catch OOM, Compact LOH, then retry allocation". It would be FAR more elegant if the .NET runtime would simply do this for us!... then if after LOH Compaction, and OOM occurs again, then it would actually throw the exception, and maybe crash your app.
Otherwise, we're forced to "over compensate" and have many forced Compaction of LOH, "just-in-case". And that is so non-elegant and not nearly as effective as simply having .NET runtime do this for us.
Essentially, this feature would automatically change many CRITICAL exceptions, into a simple "few second hiccup" at worst, while alleviating much stress from memory-intensive .NET apps.
Is this something the .NET runtime could feasibly do for us?
Beta Was this translation helpful? Give feedback.
All reactions