Spawn an elixir process w/ heap memory limits

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

2 Likes

Really curious about this. @rvirding or @bjorng pardon the direct mention – do you know of such a possibility?

1 Like

sure:

Process.flag(:max_heap_size, heap_size()) :: heap_size()

See: Erlang -- erlang

7 Likes

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

5 Likes