Why Span<MyStruct> arr = stackalloc MyStruct[10]; allocated memory on heap? #93895
-
Hi. I have code
} internal class Program
} I am dont understood why stackalloc MyStruct[10] allocated memory on heap. Can you to describe? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
What makes you think it allocates memory on the heap? |
Beta Was this translation helpful? Give feedback.
-
Please look screenshot |
Beta Was this translation helpful? Give feedback.
-
Thanks you for your comment. Possible exists visual tool/pluggin for debugging stack? |
Beta Was this translation helpful? Give feedback.
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).