I’m implementing a language runtime with a REPL in Rust. It’s not typical that it runs out of memory, but in those rare events it does, I want to catch the allocation error and print a message to the screen indicating the lack of available memory. The problem is that there seems to be nothing to catch… when a memory limitation is imposed with ulimit, for example, the response of the REPL to a lack of memory is to fail silently and return to the prompt. I thought with the introduction of custom allocators and catchable panics, this would be easier… has anyone done anything similar? Thanks.
When you are talking about
ulimit are you talking about the stack size? Afaik there’s no
ulimit for the heap.
Can you specify that please?
I’m talking about virtual memory, which to my admittedly limited knowledge, affects the heap size (or is the heap? I’m not entirely sure). See this issue for an example:
You’ll be able to set
oom=panic, which you can catch, once this RFC is done: