Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to handle globally OutOfMemory exception in large project #48157

Open
plachor opened this issue Feb 11, 2021 · 5 comments
Open

How to handle globally OutOfMemory exception in large project #48157

plachor opened this issue Feb 11, 2021 · 5 comments
Labels
area-VM-coreclr question Answer questions and provide assistance, not an issue with source code or documentation.
Milestone

Comments

@plachor
Copy link

plachor commented Feb 11, 2021

Hi, I'm working on core components that are used by other developers to create a working application. Within my core components there is a global exception handling strategy were we handle domain and unhandled exceptions. Yet I do not fully control how my components will be used by end-developer. So end-developer can handle exceptions that I would wish him not to be able too. For instance OutOfMemory exception.

We were excited once netcore3.1 started to handle correctly memory limits in containerized environments. We stopped seeing containers being killed by OOM killer without being able to log anything or given any chance to perform graceful shutdown.

But after several months we see that in our case for OOM's best thing we can do is to perform a restart to ensure container is healthy. This is also suggested by documentation. However in my case I do not fully control how my components are being used. Additionally there are many entry points like request pipeline, background services, asynchronous message bus were such exception can occur. For background services we might need to wait for #43637 to be able to handle it correctly.

I'm hoping to find a single place where I could express that OutOfMemory is fatal exception that it cannot be suppressed by end developer using try-catch block. Or other way around, looking for notification that it occurred and was handled somewhere so I can log it and perform graceful shutdown.

Are there any options for me, or am I forced to ensure that each try-catch is not by any chance handling OutOfMemory exception?

@dotnet-issue-labeler
Copy link

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.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged New issue has not been triaged by the area owner label Feb 11, 2021
@danmoseley
Copy link
Member

Adding VM label as such a hook would be in the runtime itself.

@SimonCropp
Copy link
Contributor

@danmoseley would any hook theoretically be possible? wouldnt calling it likely require memory to be allocated?

@danmoseley
Copy link
Member

It's not my area. @janvorli

@KalleOlaviNiemitalo
Copy link

Could the component add a handler for AppDomain.FirstChanceException and detect OutOfMemoryException that way? The documentation specifically suggests using this for "infrastructure-related exceptions such as out-of-memory".

@mangod9 mangod9 removed the untriaged New issue has not been triaged by the area owner label Jul 6, 2021
@mangod9 mangod9 added this to the Future milestone Jul 6, 2021
@mangod9 mangod9 added the question Answer questions and provide assistance, not an issue with source code or documentation. label Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-VM-coreclr question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

5 participants