Last active
June 2, 2023 04:51
-
-
Save xuwei-k/e2c0f105a7b3a149689f2c034eb6fa1c to your computer and use it in GitHub Desktop.
jol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scalaVersion := "3.3.0" | |
libraryDependencies += "org.openjdk.jol" % "jol-core" % "0.17" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Welcome to Scala 3.3.0 (11.0.19, Java OpenJDK 64-Bit Server VM). | |
Type in expressions for evaluation. Or try :help. | |
scala> org.openjdk.jol.info.ClassLayout.parseClass(classOf[::[?]]).toPrintable | |
# WARNING: Unable to get Instrumentation. Dynamic Attach failed. You may add this JAR as -javaagent manually, or supply -Djdk.attach.allowAttachSelf | |
# WARNING: Unable to attach Serviceability Agent. Unable to attach even with module exceptions: [org.openjdk.jol.vm.sa.SASupportException: Sense failed., org.openjdk.jol.vm.sa.SASupportException: Sense failed., org.openjdk.jol.vm.sa.SASupportException: Sense failed.] | |
val res0: String = "scala.collection.immutable.$colon$colon object internals: | |
OFF SZ TYPE DESCRIPTION VALUE | |
0 8 (object header: mark) N/A | |
8 4 (object header: class) N/A | |
12 4 java.lang.Object $colon$colon.head N/A | |
16 4 scala.collection.immutable.List $colon$colon.next N/A | |
20 4 (object alignment gap) | |
Instance size: 24 bytes | |
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total | |
" | |
scala> org.openjdk.jol.info.ClassLayout.parseClass(classOf[List[?]]).toPrintable | |
val res1: String = "scala.collection.immutable.List object internals: | |
OFF SZ TYPE DESCRIPTION VALUE | |
0 8 (object header: mark) N/A | |
8 4 (object header: class) N/A | |
12 4 (object alignment gap) | |
Instance size: 16 bytes | |
Space losses: 0 bytes internal + 4 bytes external = 4 bytes total | |
" | |
scala> org.openjdk.jol.info.ClassLayout.parseClass(classOf[LazyList[?]]).toPrintable | |
val res2: String = "scala.collection.immutable.LazyList object internals: | |
OFF SZ TYPE DESCRIPTION VALUE | |
0 8 (object header: mark) N/A | |
8 4 (object header: class) N/A | |
12 1 boolean LazyList.scala$collection$immutable$LazyList$$stateEvaluated N/A | |
13 1 boolean LazyList.midEvaluation N/A | |
14 1 boolean LazyList.bitmap$0 N/A | |
15 1 (alignment/padding gap) | |
16 4 scala.collection.immutable.LazyList.State LazyList.scala$collection$immutable$LazyList$$state N/A | |
20 4 scala.Function0 LazyList.lazyState N/A | |
Instance size: 24 bytes | |
Space losses: 1 bytes internal + 0 bytes external = 1 bytes total | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment