Stack safety check

RubycainRemora

New member
Joined
Jul 24, 2025
Messages
1
Programming Experience
Beginner
Hello everyone, i am interested of how to do a stack safety check to prevent stackoverflows

I have a program functionality that does a lot of string manipulations, then I've heard about Span<T>, ReadOnlySpan<T> and stackalloc keyword.

I was thinking it could be a good optimization if we utilise this, since the methods that manipulate the strings are "isolated", so the strings lifetime is limited inside those methods.

But to make sure it is safe, i wanted to see if there is a way to check if we have enough space on the stack to still allocate mem there or not.

Thanks!
 
C# strings live in the heap.
 
Back
Top Bottom