code: private long getMemoryUsage() {
      long totalPageSize = 0;
      for (MemoryBlock page : allocatedPages) {
        totalPageSize += page.size();
      }
      return ((inMemSorter == null) ? 0 : inMemSorter.getMemoryUsage()) + totalPageSize;
    }
docs: Return the total memory usage of this sorter, including the data pages and the sorter's pointer
  array.