Erlang: How to limit the memory allocated to a process

I ask if it is possible to limit the memory (heap or stack) allocated to a particular process so that this process cannot exceed it. Maybe something like "process_flag (min_heap_size, MinHeapSize)", but for maximum heap.

+4
source share
2 answers

You can build some kind of gen_server tracking process that periodically checks the assigned processes for memory and kills them if it exceeds a certain amount.

Using a combination of process_info(Pid, memory). calls process_info(Pid, memory). and exit(Pid, Reason) , this should be quite manageable.

+6
source

You can use spawn_opt with max_heap_size

+1
source

All Articles