News for hackers. Stuff that matters.
Re:Dealing with Out-of-Memory Conditions in Rust by pornel on Saturday August 14, 2021 @04:32PM (#28183713)
It's bonkers to allow programs to destabilize the whole machine to the point that the kernel has to start killing off processes just to survive.

I use https://lib.rs/cap which self-imposes memory limit on the process. Setting that limit below cgroup limit allows programs to actually handle OOM before they get killed by the OS (if only Rust's libstd wasn't so eager to self-abort anyway).

Re:Dealing with Out-of-Memory Conditions in Rust by creata on Saturday August 14, 2021 @08:28PM (#28185169)
> I use https://lib.rs/cap which self-imposes memory limit on the process.

How do you choose that limit?

Re:Dealing with Out-of-Memory Conditions in Rust by pornel on Saturday August 14, 2021 @08:58PM (#28185318)
In case of servers/vm/containers you probably know how much RAM you've provisioned, so set it to that minus whatever other processes need to live.

For desktop applications it's tough. It may be just an arbitrarily high amount you don't expect to hit during normal operation. If you need to work with variable-size data, then it could be `size_of_file_being_opened * x` if you can predict the `x`.