The Large Object Heap (LOH) is a special area of the Garbage Collector’s (GC) heap reserved exclusively for very large objects.While most objects are created on the Small Object Heap (SOH)—which contains Gen 0, 1, and 2—objects larger than a specific threshold are placed directly on the LOH.

Tip

Analogy: Think of the SOH as your main house and the LOH as a separate, oversized garage.
Everyday items go in the house, but bulky things like a car or boat go straight into the garage because they are costly to handle and don’t fit well inside.


Key Characteristics

  • Size Threshold
    Objects that are 85,000 bytes or larger are allocated on the LOH.
    (This value is configurable.)

  • Collection Rules
    The LOH is logically part of Gen 2.
    → It is only cleaned during a full, expensive Gen 2 GC.
    → Like other generations, it has its own allocation budget, and when exhausted, it triggers a Gen 2 GC.

  • Performance Impact
    Creating and destroying many large objects = LOH churn.
    → This is very bad for performance, as it causes frequent Gen 2 collections.

  • Compaction
    By default, the LOH is not compacted.
    → Over time, it can become fragmented with empty gaps between surviving objects.
    Exception: Inside a container with a memory limit, LOH compaction does occur.


Visualizing SOH vs LOH 🏠🚛

flowchart LR
    A[SOH - Small Object Heap] -->|Gen 0| B[Short-lived objects]
    A -->|Gen 1| C[Survivors promoted]
    A -->|Gen 2| D[Long-lived objects]

    A -.->|Too Large| E[LOH - Large Object Heap / Oversized Garage]
    E -->|Only cleaned with Full Gen 2 GC| F[Expensive Collection]