We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Exploring Recursive Functions and Stack Overflow in Elixir
97
clicks
Source: reddit.com
hezwat began by attempting to create a stack overflow in Elixir by deliberately omitting the base case in a recursive function. However, this did not lead to a stack overflow but rather to uncontrolled counting down. Further discussion revealed that Elixir's virtual machine doesn't have a fixed stack size and instead continuously allocates memory for the stack. With insights from other users, like ScrimpyCat, hezwat was able to modify the recursive function and wrap it in a try block to remove the optimization and cause a memory allocation loop. This led to memory consumption to the point of a VM crash, proving that while a traditional stack overflow might not occur in Elixir, the system will eventually run into issues as it consumes all available memory.
Related posts
© HashMerge 2024