Re:Dealing with Out-of-Memory Conditions in Rust
by dnautics on Saturday August 14, 2021 @10:07AM
(#28180752)
Just code as normal and when you run into a problem, reassign the default allocator for the struct/object? Not possible for many PLs, hard for some but basically trivial (1 LOC per struct/object) for others.
Some PLs come with test suites that give you a failing allocator, so you can even easily test to make sure this looping condition resolves sanely.
The trouble is that you may not know beforehand what exactly is going to be needed. And you might need maybe a library call and the library does dynamic allocation in it and you either have no idea about it (until you find out the hard way) or no way to help it.
So in the end maybe you can take some extremely simple action like writing something to log or show a widget, but that's about it.