Serialized object size vs in memory object size in Java

前端 未结 2 759
忘掉有多难
忘掉有多难 2021-01-11 18:13

Is there a way of estimating (roughly) in memory object size from Serialized object size in Java

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 19:18

    A very nice Tool for this challenge: https://github.com/jbellis/jamm

    From the readme.txt:

    MemoryMeter is as accurate as java.lang.instrument.Instrumentation.getObjectSize, which only claims to provide "approximate" results, but in practice seems to work as expected.

    MemoryMeter uses reflection to crawl the object graph for measureDeep. Reflection is slow: measuring a one-million object Cassandra Memtable (that is, 1 million children from MemoryMeter.countChildren) took about 5 seconds wall clock time.

提交回复
热议问题