#935 – Large Objects Are Allocated on the Large Object Heap

The managed heap is the area in memory where reference-typed objects are allocated.  When you create a new object, a portion of the managed heap is allocated for the object.

In reality, objects are stored on either the Small Object Heap (SOH) or the Large Object Heap (LOH).  Objects that are larger than 85,000 bytes are allocated on the LOH.  All other objects are allocated on the SOH.

Other differences between the two heaps:

  • The SOH is generational–objects belong to generation 0, 1, or 2.  The LOH is not sub-divided into generations
  • The LOH is only garbage collected when generation 2 of the SOH is collected.  (I.e. Rarely)
  • After the LOH is garbage collected, the heap is not compacted.  This results in the memory becoming fragmented and requires maintaining a linked list of free blocks.  (The SOH is compacted after every collection).
  • Allocation on the LOH can be slower than the SOH, due to the fragmentation.

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

5 Responses to #935 – Large Objects Are Allocated on the Large Object Heap

  1. Pingback: SQL SELECT Previous Next Value: The Daily Six Pack September 23, 2013

  2. Brondahl says:

    larger than 85,000 what?

Leave a comment