Bohn Bohn -4 years ago 72
C# Question

What exception do we get upon low RAM in memory?

If I am doing a recursive algorithm to traverse a tree...and I know it has a lot of data, huge..and after like 20 minutes I get a "Stack Overflow" exception. But StackOverFlow might be because of some other error in code , maybe because of an infinite-loop ... so I am just trying to make sure this SOF error I get in VisualStudio is because my recursive algorithm is running out of RAM and not because of other errors...Do we have a special type of error message or exception when we are running out of memory in a recursive algorithm at all?

Answer Source

System.OutOfMemoryException can be thrown when memory is low. System.StackOverflowException is that you've busted the call stack with something recursively ultra-complex or without a terminating case.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download