@Override
  public void close() {
    // 'refCnt' here tracks the scanners opened on segments which directly refer to this
    // MSLAB. The individual MSLABs this refers also having its own 'refCnt'. The usage of
    // the variable in close() and decScannerCount() is as as that in HeapMemstoreLAB. Here the
    // close just delegates the call to the individual MSLABs. The actual return of the chunks to
    // MSLABPool will happen within individual MSLABs only (which is at the leaf level).
    // Say an ImmutableMemStoreLAB is created over 2 HeapMemStoreLABs at some point and at that time
    // both of them were referred by ongoing scanners. So they have > 0 'refCnt'. Now over
    // the new Segment some scanners come in and this MSLABs 'refCnt' also goes up and
    // then come down on finish of scanners. Now a close() call comes to this Immutable MSLAB. As
    // it's 'refCnt' is zero it will call close() on both of the Heap MSLABs. Say by that
    // time the old scanners on one of the MSLAB got over where as on the other, still an old
    // scanner is going on. The call close() on that MSLAB will not close it immediately but will
    // just decrease it's 'refCnt' and it's 'refCnt' still > 0. Later once the old scan is
    // over, the decScannerCount() call will do the actual close and return of the chunks.
    if (!this.closed.compareAndSet(false, true)) {
      return;
    }
    // When there are still on going scanners over this MSLAB, we will defer the close until all
    // scanners finish. We will just decrease it's 'refCnt'. See #decScannerCount(). This will be
    // called at end of every scan. When it's 'refCnt' reached 0, we will do the actual close then.
    this.refCnt.release();
  }
The process of merging assumes all cells are allocated on mslab. There is a rare case in which
the first immutable segment, participating in a merge, is a CSLM. Since the CSLM hasn't been
flattened yet, and there is no point in flattening it (since it is going to be merged), its big
cells (for whom size > maxAlloc) must be copied into mslab. This method copies the passed cell
into the first mslab in the mslabs list, returning either a new cell instance over the copied
data, or null when this cell cannt be copied.
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ImmutableMemStoreLAB.java