Skip to main content

Posts

Showing posts with the label OOP

What is Stack and Heap

We are discussing about memory management, how the memory of the computer is organized for a running program. Ok lets go to discuss :-  When a program is loaded into memory, it is organized into three areas of memory, called segments: the text segment ,  stack segment , and  heap segment . The text segment:  sometimes also called the code segment  is where the compiled code of the program itself resides. The remaining two areas of system memory is where storage may be allocated by the compiler for data storage. Two areas are called Stack and Heap Stack: Stack is a data structure in memory used for storing items in last in first out manner. The  stack contains local variables and the call stack. In C#, Value types variable are stored directly on the stack.  The advantage of using the stack to store variables, is that memory is managed . we don't have to allocate memory by hand, or free it once we don't need it any more. What's m...