code: public void putMemory(final WritableMemory dstMem, final boolean compact) {
      if (isDirect() && (isCompact() == compact)) {
        final Memory srcMem = getMemory();
        srcMem.copyTo(0, dstMem, 0, getStorageBytes());
      } else {
        final byte[] byteArr = toByteArray(compact);
        final int arrLen = byteArr.length;
        final long memCap = dstMem.getCapacity();
        if (memCap < arrLen) {
          throw new SketchesArgumentException(
                  "Destination Memory not large enough: " + memCap + " < " + arrLen);
        }
        dstMem.putByteArray(0, byteArr, 0, arrLen);
      }
    }
docs: Puts the current sketch into the given Memory if there is sufficient space, otherwise,
  throws an error.
  
  @param dstMem the given memory.
  @param compact if true, compacts and sorts the base buffer, which optimizes merge
  performance at the cost of slightly increased serialization time.