SlideShare a Scribd company logo
1 of 9
Learn Microsoft Asp.Net
Garbage Collection
Visit: www.crbtech.in/Dot-Net-Training/
The main function of the garbage collector, as far as .NET framework is
concerned, is allocating and releasing the memory required for the application
to run. Whenever you define or create a new object, the .NET library better
known as the Common Language Runtime or CLR in short, is responsible for
assigning memory to the recently created object. The memory is borrowed from
the managed heap which can be called as an ocean of memory in layman’s
language. As far as this heap is available, the runtime library goes on to
allocate memory for newer objects created. One thing you must know as a
developer is that, the memory available is limited. After repeated use of it, the
garbage collector comes into the picture. It collects and frees the memory. The
optimizing engine decides the time for garbage collection and commands the
collector accordingly. The time is decided based on the memory allocations
made.
What the garbage collector does is that, it looks for those objects stored in the
memory that are no more in use. It does the necessary operation to free their
memory and make it available for further use.
Whether the application is a web based one or a windows based one; memory
allocation and management is vital and a cause of concern. Therefore, one can
say that the garbage collector performs a very important task as far as .NET
framework is concerned. Now let us see the advantages of garbage collector.
Advantages of Garbage Collector in .NET:
1.Makes memory allocation for objects from the available managed heap.
2.Ensures that one object does not occupy other one’s memory. Thus, keeping an
eye on memory safety and security.
3.We can continue to develop an application without worrying about whether
sufficient memory is available for developing and running it. Garbage collector will
take care of it at the back end.
4.Frees the memory of those objects that are not in use and makes it available for
allocation in the future.
How is Memory Allocated in Managed Heap?
For creating a new object, the new operator is used. This new operator ensures
that the required memory or space by the object is available in the reserved
region. It also commits the storage space if needed. If the space is optimum and
the object fits, then the object pointer points in the heap and the constructor is
given a call. The address of the object is thus fetched.
The heap or the managed heap is nothing but, a bunch of memory segments.
Each of them is of fixed size about 16MB. When memory is to be assigned to a
new object, the next memory location on the heap is allocated. If there is sufficient
memory available, then the collector is not called in. If not, the garbage collector
searches and frees the old dead objects in the heap. Then new object is allocated
memory.
Some Important Points About Garbage Collector:
1.Memory allocation is carried out within a contiguous range of addresses.
2.The segments are divided into Gen 0, Gen 1 and Gen 2. Gen 0 and Gen 1 form
ephemeral segment. Gen2 are the next segments. Large object heap are yet
another set of segments.
3.Older objects are situated at lower memory locations, while newer are present at
higher address locations.
4.On a regular basis, the heap is freed of garbage and memory is made available
for newer objects.
5.Objects are never separated by gaps in the memory.
This was the basic part of garbage collection in .NET.
Learn .net courses in pune to enhance your knowledge in dept.
Related articles:
Microsoft .Net Framework 4.0| 4.5 | 4.6 for Beginners
What is New About Open Source .Net?
THANK YOU…!

More Related Content

Similar to Learn Microsoft Asp.Net Garbage Collection

Memory Leaks in Android Applications
Memory Leaks in Android ApplicationsMemory Leaks in Android Applications
Memory Leaks in Android ApplicationsLokesh Ponnada
 
Memory profiler and garbage collector in C#
Memory profiler and garbage collector in C#Memory profiler and garbage collector in C#
Memory profiler and garbage collector in C#Wipro
 
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12sidg75
 
Garbage collection
Garbage collectionGarbage collection
Garbage collectionMudit Gupta
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1rohassanie
 
02D-Memory Management in Java.pptx
02D-Memory Management in Java.pptx02D-Memory Management in Java.pptx
02D-Memory Management in Java.pptxAnhNhatNguyen5
 
Chronicles Of Garbage Collection (GC)
Chronicles Of Garbage Collection (GC)Chronicles Of Garbage Collection (GC)
Chronicles Of Garbage Collection (GC)Techizzaa
 
Garbage collection algorithms
Garbage collection algorithmsGarbage collection algorithms
Garbage collection algorithmsachinth
 
Is2215 lecture5 lecturer_g_cand_classlibraries
Is2215 lecture5 lecturer_g_cand_classlibrariesIs2215 lecture5 lecturer_g_cand_classlibraries
Is2215 lecture5 lecturer_g_cand_classlibrariesdannygriff1
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt Arpita Naik
 
307d791b 3343-2e10-f78a-e1d50c7cf89a
307d791b 3343-2e10-f78a-e1d50c7cf89a307d791b 3343-2e10-f78a-e1d50c7cf89a
307d791b 3343-2e10-f78a-e1d50c7cf89avijaysrirams
 
01class_object_references & 02Generation_GC.pptx
01class_object_references & 02Generation_GC.pptx01class_object_references & 02Generation_GC.pptx
01class_object_references & 02Generation_GC.pptxssuser95922e
 
Why using finalizers is a bad idea
Why using finalizers is a bad ideaWhy using finalizers is a bad idea
Why using finalizers is a bad ideaPVS-Studio
 
Memory allocation for real time operating system
Memory allocation for real time operating systemMemory allocation for real time operating system
Memory allocation for real time operating systemAsma'a Lafi
 
Basic Garbage Collection Techniques
Basic  Garbage  Collection  TechniquesBasic  Garbage  Collection  Techniques
Basic Garbage Collection TechniquesAn Khuong
 
Vmreport
VmreportVmreport
Vmreportmeru2ks
 
Memory Management & Garbage Collection
Memory Management & Garbage CollectionMemory Management & Garbage Collection
Memory Management & Garbage CollectionAbhishek Sur
 
Heap Memory Management.pptx
Heap Memory Management.pptxHeap Memory Management.pptx
Heap Memory Management.pptxViji B
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuningosa_ora
 
Mule memory leak issue
Mule memory leak issueMule memory leak issue
Mule memory leak issueJeeHyunLim
 

Similar to Learn Microsoft Asp.Net Garbage Collection (20)

Memory Leaks in Android Applications
Memory Leaks in Android ApplicationsMemory Leaks in Android Applications
Memory Leaks in Android Applications
 
Memory profiler and garbage collector in C#
Memory profiler and garbage collector in C#Memory profiler and garbage collector in C#
Memory profiler and garbage collector in C#
 
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
Garbage Collection, Tuning And Monitoring JVM In EBS 11i And R12
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
 
Chapter 2 part 1
Chapter 2 part 1Chapter 2 part 1
Chapter 2 part 1
 
02D-Memory Management in Java.pptx
02D-Memory Management in Java.pptx02D-Memory Management in Java.pptx
02D-Memory Management in Java.pptx
 
Chronicles Of Garbage Collection (GC)
Chronicles Of Garbage Collection (GC)Chronicles Of Garbage Collection (GC)
Chronicles Of Garbage Collection (GC)
 
Garbage collection algorithms
Garbage collection algorithmsGarbage collection algorithms
Garbage collection algorithms
 
Is2215 lecture5 lecturer_g_cand_classlibraries
Is2215 lecture5 lecturer_g_cand_classlibrariesIs2215 lecture5 lecturer_g_cand_classlibraries
Is2215 lecture5 lecturer_g_cand_classlibraries
 
Cache memory ppt
Cache memory ppt  Cache memory ppt
Cache memory ppt
 
307d791b 3343-2e10-f78a-e1d50c7cf89a
307d791b 3343-2e10-f78a-e1d50c7cf89a307d791b 3343-2e10-f78a-e1d50c7cf89a
307d791b 3343-2e10-f78a-e1d50c7cf89a
 
01class_object_references & 02Generation_GC.pptx
01class_object_references & 02Generation_GC.pptx01class_object_references & 02Generation_GC.pptx
01class_object_references & 02Generation_GC.pptx
 
Why using finalizers is a bad idea
Why using finalizers is a bad ideaWhy using finalizers is a bad idea
Why using finalizers is a bad idea
 
Memory allocation for real time operating system
Memory allocation for real time operating systemMemory allocation for real time operating system
Memory allocation for real time operating system
 
Basic Garbage Collection Techniques
Basic  Garbage  Collection  TechniquesBasic  Garbage  Collection  Techniques
Basic Garbage Collection Techniques
 
Vmreport
VmreportVmreport
Vmreport
 
Memory Management & Garbage Collection
Memory Management & Garbage CollectionMemory Management & Garbage Collection
Memory Management & Garbage Collection
 
Heap Memory Management.pptx
Heap Memory Management.pptxHeap Memory Management.pptx
Heap Memory Management.pptx
 
Profiler Guided Java Performance Tuning
Profiler Guided Java Performance TuningProfiler Guided Java Performance Tuning
Profiler Guided Java Performance Tuning
 
Mule memory leak issue
Mule memory leak issueMule memory leak issue
Mule memory leak issue
 

Recently uploaded

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 

Recently uploaded (20)

How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 

Learn Microsoft Asp.Net Garbage Collection

  • 1. Learn Microsoft Asp.Net Garbage Collection Visit: www.crbtech.in/Dot-Net-Training/
  • 2. The main function of the garbage collector, as far as .NET framework is concerned, is allocating and releasing the memory required for the application to run. Whenever you define or create a new object, the .NET library better known as the Common Language Runtime or CLR in short, is responsible for assigning memory to the recently created object. The memory is borrowed from the managed heap which can be called as an ocean of memory in layman’s language. As far as this heap is available, the runtime library goes on to allocate memory for newer objects created. One thing you must know as a developer is that, the memory available is limited. After repeated use of it, the garbage collector comes into the picture. It collects and frees the memory. The optimizing engine decides the time for garbage collection and commands the collector accordingly. The time is decided based on the memory allocations made.
  • 3.
  • 4. What the garbage collector does is that, it looks for those objects stored in the memory that are no more in use. It does the necessary operation to free their memory and make it available for further use. Whether the application is a web based one or a windows based one; memory allocation and management is vital and a cause of concern. Therefore, one can say that the garbage collector performs a very important task as far as .NET framework is concerned. Now let us see the advantages of garbage collector.
  • 5. Advantages of Garbage Collector in .NET: 1.Makes memory allocation for objects from the available managed heap. 2.Ensures that one object does not occupy other one’s memory. Thus, keeping an eye on memory safety and security. 3.We can continue to develop an application without worrying about whether sufficient memory is available for developing and running it. Garbage collector will take care of it at the back end. 4.Frees the memory of those objects that are not in use and makes it available for allocation in the future.
  • 6. How is Memory Allocated in Managed Heap? For creating a new object, the new operator is used. This new operator ensures that the required memory or space by the object is available in the reserved region. It also commits the storage space if needed. If the space is optimum and the object fits, then the object pointer points in the heap and the constructor is given a call. The address of the object is thus fetched. The heap or the managed heap is nothing but, a bunch of memory segments. Each of them is of fixed size about 16MB. When memory is to be assigned to a new object, the next memory location on the heap is allocated. If there is sufficient memory available, then the collector is not called in. If not, the garbage collector searches and frees the old dead objects in the heap. Then new object is allocated memory.
  • 7. Some Important Points About Garbage Collector: 1.Memory allocation is carried out within a contiguous range of addresses. 2.The segments are divided into Gen 0, Gen 1 and Gen 2. Gen 0 and Gen 1 form ephemeral segment. Gen2 are the next segments. Large object heap are yet another set of segments. 3.Older objects are situated at lower memory locations, while newer are present at higher address locations. 4.On a regular basis, the heap is freed of garbage and memory is made available for newer objects. 5.Objects are never separated by gaps in the memory.
  • 8. This was the basic part of garbage collection in .NET. Learn .net courses in pune to enhance your knowledge in dept. Related articles: Microsoft .Net Framework 4.0| 4.5 | 4.6 for Beginners What is New About Open Source .Net?