Heap, Stack, Boxing and Unboxing, Performance ... let's order things! #4
Replies: 2 comments 2 replies
-
Thanks for sharing, it was a nice read, well done!I would like to add a subtle detail on "stack"; Counterintuitively stack grows downward even though we tend to visualize it - like a stack designed by arrays, last item is of the highest index or memory address - the truth is that last item put on "stack frame" will be having the lowest memory address.
public struct Model
{
int a = 10; // memory address on stack in decimal: 2866988798
int b = 20; // memory address on stack in decimal: 2866988794
// storing the reference address on stack
ItemClass c = new ItemClass(); // memory address on stack in decimal: 2866988790
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
|
In C# records is a value type, but when it converts to IL it's been as a class! and classes are reference types. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Heap, Stack, Boxing and Unboxing, Performance ... let's order things!
In this article I will shade some lights on some of the most used terms which seems very confusing especially for beginners: heap, stack and boxing and unboxing.
Furthermore we will also encounter internet wisdom like:
Value types get stored on the stack. Reference types on the heap
We discuss why this is wrong and what the hell performance has to do with it?
https://steven-giesel.com/blogPost/9a40d278-9a9f-49fe-bbfd-2d813a58e73e
Beta Was this translation helpful? Give feedback.
All reactions