@SuppressWarnings("unused")
  private static void dumpHeap(final String filePath, final boolean live) {
    try {
      MBeanServer server = ManagementFactory.getPlatformMBeanServer();
      HotSpotDiagnosticMXBean mxBean =
          ManagementFactory.newPlatformMXBeanProxy(
              server, "com.sun.management:type=HotSpotDiagnostic", HotSpotDiagnosticMXBean.class);
      mxBean.dumpHeap(filePath, live);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Utility method useful for producing a heap dump when calculating the memory size of a new
object. Note that the file is not overwritten, so you need to remove it to create a new heap
dump.

@param filePath where to save the heap dump
@param live true to only include live objects
ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java