Skip to content

Why Span<MyStruct> arr = stackalloc MyStruct[10]; allocated memory on heap? #93895

Answered by Clockwork-Muse
P9avel asked this question in General
Discussion options

You must be logged in to vote

What is it, exactly, that you're trying to do? You can already see the contents of things on the stack as part of normal debugging, even if it isn't always made clear that they're there (eg, local variables).
Most things on the stack are going to be there are there by definition of what they are (structs, stackalloc-ed variables, etc), so something that additionally lists them "on stack" isn't terribly helpful (unlike heap, where items can live hide or persist in some situations).

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@svick
Comment options

Comment options

You must be logged in to vote
2 replies
@Clockwork-Muse
Comment options

Answer selected by P9avel
@P9avel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants