Function to check how much stack is available

If there any way to find out how much stack is available (unallocated)?

I want to use this to avoid a "hard" stack overflow.

1 Like

It is OS-specific -- you can see how std does it on unix targets here:

But even that is often inaccurate for the main thread, which may dynamically grow stack:

I've no experience using it myself but maybe the stacker crate would be useful here? (It's owned and maintained by the Rust compiler team.)

(Not to be confused with stakker.)

1 Like

Thanks, that seems to be working perfectly for me.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.