Instead of throwing, you just abort the program. If you are running part of a backend service this is reasonable, under some assumptions.
If you fail to allocate memory, there’s a good chance that your process can’t continue servicing requests anyway. So, it’s a good tradeoff to abort. The client can retry later or with a different backend, and the job scheduler can start another instance of the process.
If you fail to allocate memory, there’s a good chance that your process can’t continue servicing requests anyway. So, it’s a good tradeoff to abort. The client can retry later or with a different backend, and the job scheduler can start another instance of the process.