#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.
Advertisements

About Sean
Software developer in the Twin Cities area, passionate about .NET technologies. Equally passionate about my own personal projects related to family history and preservation of family stories and photos.

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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: