Is there a way to spawn an elixir process w/ heap memory limit, to say something like:
start this process, but if it ever hits > 1 MB heap, kill it
Is there a way to spawn an elixir process w/ heap memory limit, to say something like:
start this process, but if it ever hits > 1 MB heap, kill it
sure:
Process.flag(:max_heap_size, heap_size()) :: heap_size()
Exactly what I needed. Thanks!
Awesome, thank you.
Beware that large binaries are stored off-heap, so this limit won’t apply to them. See Sand: an Elixir sandbox
A typical example of this is: downloading a large file with HTTPoison (without streaming), as I just “discovered”.
I am looking for ways to automatically detect those extra non-streaming downloads on a given codebase.
Process.info(self())[:total_heap_size] won’t report it at all.
Process.flag(:max_heap_size, 100_000) won’t kill the process with a 500MB file.
Interesting article on the topic!