private void maybeExpandCapacity(final int newActiveWords) {
    if (activeWords >= newActiveWords) return;

    int neededSize = newActiveWords * Bytes32.SIZE;
    if (neededSize > memBytes.length) {
      int newSize = Math.max(neededSize, memBytes.length * 2);
      byte[] newMem = new byte[newSize];
      System.arraycopy(memBytes, 0, newMem, 0, memBytes.length);
      memBytes = newMem;
    }
    activeWords = newActiveWords;
  }
Expands the memory to the specified number of active words.

@param newActiveWords The new number of active words to expand to.
evm/src/main/java/org/hyperledger/besu/evm/frame/Memory.java