@Test
  public void chainIdSize() {

    BigInteger chainId = BigInteger.valueOf(1);
    Optional<BigInteger> maybeChainId = Optional.of(chainId);

    final ClassLayout cl = ClassLayout.parseInstance(maybeChainId);
    System.out.println(cl.toPrintable());
    LongAdder size = new LongAdder();
    size.add(cl.instanceSize());
    System.out.println("Base chainId size: " + size);

    GraphVisitor gv =
        gpr -> {
          size.add(gpr.size());
          System.out.println(
              "("
                  + size
                  + ")["
                  + gpr.size()
                  + ", "
                  + gpr.path()
                  + ", "
                  + gpr.klass().toString()
                  + "]");
        };

    GraphWalker gw = new GraphWalker(gv);

    gw.walk(maybeChainId);

    assertThat(size.sum()).isEqualTo(OPTIONAL_CHAIN_ID_SIZE);
  }
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