OpenJDK JRE vs HotSpot JVM? ObjectSizeCalculator only works with HotSpot

0

There is a class in the java ext classes that computes object sizes but it only works with the HotSpot JVM. jdk.nashorn.internal.ir.debug.ObjectSizeCalculator
https://stackoverflow.com/a/39406536
https://stackoverflow.com/questions/52353/in-java-what-is-the-best-way-to-determine-the-size-of-an-object#comment84178865_39406536

What is the status of HotSpot? It took me a while to figure out that the error mesage was due to the JVM version:
java.lang.NoClassDefFoundError: Could not initialize class jdk.nashorn.internal.ir.debug.ObjectSizeCalculator$CurrentLayout

This would be very useful with spark RDDs during debug...

質問済み 6年前418ビュー
1回答
0

I'm still curious about HotSpot but a different way to solve this is something like this using openjdk jol project:

import org.openjdk.jol

val l = List(1,2,3)

// Convert Any into AnyRef: https://stackoverflow.com/a/23892913
val jo = l.asInstanceOf[AnyRef]
val gl = jol.info.GraphLayout.parseInstance(jo)
gl.totalSize()
回答済み 6年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ