@Test
  public void testLABChunkQueueWithMultipleMSLABs() throws Exception {
    Configuration conf = HBaseConfiguration.create();
    MemStoreLABImpl[] mslab = new MemStoreLABImpl[10];
    for (int i = 0; i < 10; i++) {
      mslab[i] = new MemStoreLABImpl(conf);
    }
    // launch multiple threads to trigger frequent chunk retirement
    List<Thread> threads = new ArrayList<>();
    // create smaller sized kvs
    final KeyValue kv =
      new KeyValue(Bytes.toBytes("r"), Bytes.toBytes("f"), Bytes.toBytes("q"), new byte[0]);
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
        threads.add(getChunkQueueTestThread(mslab[i], "testLABChunkQueue-" + j, kv));
      }
    }
    for (Thread thread : threads) {
      thread.start();
    }
    // let it run for some time
    Thread.sleep(3000);
    for (Thread thread : threads) {
      thread.interrupt();
    }
    boolean threadsRunning = true;
    boolean alive = false;
    while (threadsRunning) {
      alive = false;
      for (Thread thread : threads) {
        if (thread.isAlive()) {
          alive = true;
          break;
        }
      }
      if (!alive) {
        threadsRunning = false;
      }
    }
    // close the mslab
    for (int i = 0; i < 10; i++) {
      mslab[i].close();
    }
    // all of the chunkIds would have been returned back
    assertTrue("All the chunks must have been cleared",
      ChunkCreator.instance.numberOfMappedChunks() == 0);
  }
Test frequent chunk retirement with chunk pool triggered by lots of threads, making sure
there's no memory leak (HBASE-16195)
@throws Exception if any error occurred
hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMemstoreLABWithoutPool.java