News for hackers. Stuff that matters.
Re:Dealing with Out-of-Memory Conditions in Rust by ectopod on Saturday August 14, 2021 @09:07AM (#28180313)
For big infrequent allocations (like your example of loading a huge image) it is easy to use a non-default allocator that returns an error rather than aborting.

As the article notes, this is all moot if you are running on Linux though. The allocation will always succeed but if it's too big the kernel will start killing processes, quite possibly including your image viewer.

Re:Dealing with Out-of-Memory Conditions in Rust by alerighi on Saturday August 14, 2021 @12:04PM (#28181704)
In Linux allocations can fail in some situation, for example in case it's set a resource limit on memory, because it was set a memory rlimit for the process, or the cgroup that contains the process runs out of memory (so if you run the program in a container with constrained memory).
Re:Dealing with Out-of-Memory Conditions in Rust by beached_whale on Saturday August 14, 2021 @09:52AM (#28180619)
oom handling on linux is a system option and there are also ulimits