Sunday, July 14, 2019

.Net Memory Management : Garbage Collector


Allocates Objects into one of 2 heaps

SOH : Small Object Heap : <    85KB   : Allocated on Contiguous heap, Objects allocated continuously.



When Object B and Object A finishes its work.(no longer is used) it looses it root reference, when the function allocates and finishes.


Garbage collector: Reclaims memory from rootless objects.
GC: runs whenever the memory usage reaches certain threshold.
GCollector: Freezes all execution threads during Garbage Collection and hits the performance of your application.

LOH : Large                      : > = 85KB

You allocate on to heap whenever you are using new Keyword in Code.


Conditions for a garbage collection

Garbage collection occurs when one of the following conditions is true:
  • The system has low physical memory. This is detected by either the low memory notification from the OS or low memory indicated by the host.
  • The memory that is used by allocated objects on the managed heap surpasses an acceptable threshold. This threshold is continuously adjusted as the process runs.
  • The GC.Collect method is called. In almost all cases, you do not have to call this method, because the garbage collector runs continuously. This method is primarily used for unique situations and testing.



No comments:

Post a Comment

JMeter Simple Controller

  Simple Controller is just a  container  for user request.