Please enable JavaScript.
Coggle requires JavaScript to display documents.
Memory Management - Coggle Diagram
Memory Management
Memory divided into 2 parts
Stack
Stack Reserved one per Thread
Multi Threaded have their own Stack. it could be more than one
It Occupies 1 MB for 32 bit Processer and 4 MB for 64 bit processor
No gap between data and can be automatic removed after its execution
Faster
Store Value Type val1=val2 a copy of val2 to is assigned to val1 not val2 itself. They both use different memory location not the same. if you change value of val2 then value of val1 won't change
Value Type
Struct and all Simple Built In Type (Int, Decimal, Double Struct,DateTime etc) all are derived from System.ValueType
Data Stored in Stack and Static class as well
Heap
One per a Application
This is dynamic. This occupies based on our app
Data are scattered
Memory Cleaned up by Garbage Collector
Slower
Store Object/Reference Type obj1=obj2 won't create a new object just point the memory location of obj2 into the memory location of obj1. Both uses same memory location. If you change value of obj2 then obj1 value also got changed
Reference Type
Derived from all are derived from System.Object. All Classes are reference type
Data Stored in Heap
Reference Stored in Stack