Difference bwn stack and heap?????
give me a better understanding of stack and heap ??????
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Aug 20, 2014, 12:54 AM EDT
http://www.c-sharpcorner.com/UploadFile/rmcochran/csharp_memory01122006130034PM/csharp_memory.aspx
http://www.c-sharpcorner.com/UploadFile/rmcochran/csharp_memory2B01142006125918PM/csharp_memory2B.aspx
http://www.c-sharpcorner.com/UploadFile/rmcochran/chsarp_memory401152006094206AM/chsarp_memory4.aspx
http://www.c-sharpcorner.com/UploadFile/rmcochran/csharp_memory_401282006141834PM/csharp_memory_4.aspx
Abhay ShankerRank #375 · 6.7K reputationPosted Aug 20, 2014, 2:02 AM EDT
The stack is a data structure in memory used for storing items in a last-in, first-out manner (LIFO). The stack contains both local variables and the call stack. In C#, value types are stored on the stack.
The heap or managed heap is a data structure in memory where all objects—reference types—are stored. When an object is instantiated, the object is stored on the heap as a block of data containing its data members. Then, the memory address of the block is stored in a reference variable. Future references to the object are through the reference variable.
Check below links for more details:-
http://csharpcomputing.com/Tutorials/Lesson6.htm
http://www.albahari.com/valuevsreftypes.aspx
VulpesRank #55 · 29.2K reputationPosted Aug 20, 2014, 2:48 AM EDT
Value types are not always stored on the stack.
For example, if they are:
1. Static or instance fields of reference types; or
2. Static fields of value types,
then they are stored on the heap.
naimer kallis2 reputationPosted Jan 4, 2015, 8:05 PM EST
Naimer