private long sizeOfField(final Object container, final String... excludePaths) {
    final ClassLayout cl = ClassLayout.parseInstance(container);
    System.out.println(cl.toPrintable());
    System.out.println("Base container size: " + cl.instanceSize());

    LongAdder size = new LongAdder();
    size.add(cl.instanceSize());

    GraphVisitor gv =
        gpr -> {
          if (Arrays.stream(excludePaths)
              .anyMatch(excludePath -> gpr.path().contains(excludePath))) {
            System.out.println("Excluded path " + gpr.path());
          } else {
            size.add(gpr.size());
            System.out.println(
                "("
                    + size
                    + ")["
                    + gpr.size()
                    + ", "
                    + gpr.path()
                    + ", "
                    + gpr.klass().toString()
                    + "]");
            System.out.println(ClassLayout.parseClass(gpr.klass()).toPrintable());
          }
        };

    GraphWalker gw = new GraphWalker(gv);

    gw.walk(container);

    System.out.println("Container size: " + size);
    return size.sum();
  }
Field which value is dynamic and can only be calculated at runtime
ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java