jol

UseCompressedOops UseCompressedClassPointers in jdk-13 and jdk-15

一曲冷凌霜 提交于 2021-02-04 16:00:51
问题 Accidentally I have stumbled into a change in jdk-15 that I was not aware of. Suppose I have a very simple question: what is the size of an array of 3 intergers? For this, I use JOL. The code is fairly trivial: import org.openjdk.jol.info.ClassLayout; import org.openjdk.jol.vm.VM; public class Array { public static void main(String [] args){ int [] array = new int[3]; System.out.println(ClassLayout.parseInstance(array).toPrintable()); } } I run this with jdk-13 : java -Djdk.attach

What is “(something else)” in jol GraphLayout output?

半城伤御伤魂 提交于 2019-12-23 22:43:01
问题 When using jol's GraphLayout class to print the graph of objects referenced from an object instance, some of the output entries say "(something else)" instead of a type and reference path. For example, consider the following code that prints the graph of a list of 20 random Integer objects: List<Integer> foo = new Random().ints(20).boxed().collect(Collectors.toList()); System.out.println(GraphLayout.parseInstance(foo).toPrintable()); This code prints: java.util.ArrayList object externals:

What is in java object header

别等时光非礼了梦想. 提交于 2019-12-17 02:31:36
问题 Could you give me some information on what is exactly stored in object header? I know, that it's probably JVM dependent, but maybe for HotSpot at least? I'm looking for exact description specifically for a first row. I've read several information that I can't verify positively with information I find. Maybe you have a link to OpenJDK wiki that says it all? 回答1: For HotSpot: The object header consists of a mark word and a klass pointer. The mark word has word size ( 4 byte on 32 bit

Is jol a little broken under Java9?

谁说胖子不能爱 提交于 2019-12-07 02:21:42
问题 Using java-9 build 9-ea+149 and jol 0.6 . Running this simple code: ArrayList<Integer> list = new ArrayList<>(); list.add(12); System.out.println(ClassLayout.parseInstance(list).toPrintable()); Output: OFFSET SIZE TYPE DESCRIPTION VALUE 0 4 (object header) 01 00 00 00 (00000001 00000000 00000000 00000000) (1) 4 4 (object header) 00 00 00 00 (00000000 00000000 00000000 00000000) (0) 8 4 (object header) 0e 8d 00 f8 (00001110 10001101 00000000 11111000) (-134181618) 12 4 int AbstractList

Is jol a little broken under Java9?

孤人 提交于 2019-12-05 06:57:28
Using java-9 build 9-ea+149 and jol 0.6 . Running this simple code: ArrayList<Integer> list = new ArrayList<>(); list.add(12); System.out.println(ClassLayout.parseInstance(list).toPrintable()); Output: OFFSET SIZE TYPE DESCRIPTION VALUE 0 4 (object header) 01 00 00 00 (00000001 00000000 00000000 00000000) (1) 4 4 (object header) 00 00 00 00 (00000000 00000000 00000000 00000000) (0) 8 4 (object header) 0e 8d 00 f8 (00001110 10001101 00000000 11111000) (-134181618) 12 4 int AbstractList.modCount (access denied) 16 4 int ArrayList.size (access denied) 20 4 Object[] ArrayList.elementData (access

How are Java objects laid out in memory on Android?

廉价感情. 提交于 2019-12-03 15:01:28
问题 I'm fairly familiar with the layout of objects on the heap in HotSpot, but not so much for Android. For example, in a 32-bit HotSpot JVM, an object on the heap is implemented as an 8-byte header, followed by the object's fields (one byte for boolean , four bytes for a reference, and everything else as expected), laid out in some specific order (with some special rules for fields from superclasses), and padded out to a multiple of 8 bytes. I've done some research, but I can't find any Android

Why is there internal fragmentation in a Java object even if every field is 4-byte aligned?

☆樱花仙子☆ 提交于 2019-11-30 21:23:16
Intro: I used the JOL (Java Object Layout) tool to analyze the internal and external fragmentation of Java objects for research purpose. While doing so, I stumbled across the following: x@pc:~/Util$ java -jar jol-cli-0.9-full.jar internals sun.reflect.DelegatingClassLoader # WARNING: Unable to attach Serviceability Agent. You can try again with escalated privileges. Two options: a) use -Djol.tryWithSudo=true to try with sudo; b) echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope # Running 64-bit HotSpot VM. # Using compressed oop with 3-bit shift. # Using compressed klass with 3-bit shift. #

Why is there internal fragmentation in a Java object even if every field is 4-byte aligned?

跟風遠走 提交于 2019-11-30 05:44:34
问题 Intro: I used the JOL (Java Object Layout) tool to analyze the internal and external fragmentation of Java objects for research purpose. While doing so, I stumbled across the following: x@pc:~/Util$ java -jar jol-cli-0.9-full.jar internals sun.reflect.DelegatingClassLoader # WARNING: Unable to attach Serviceability Agent. You can try again with escalated privileges. Two options: a) use -Djol.tryWithSudo=true to try with sudo; b) echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope # Running

What is in java object header

爷,独闯天下 提交于 2019-11-26 13:06:42
Could you give me some information on what is exactly stored in object header? I know, that it's probably JVM dependent, but maybe for HotSpot at least? I'm looking for exact description specifically for a first row. I've read several information that I can't verify positively with information I find. Maybe you have a link to OpenJDK wiki that says it all? box For HotSpot: The object header consists of a mark word and a klass pointer. The mark word has word size ( 4 byte on 32 bit architectures, 8 byte on 64 bit architectures) and the klass pointer has word size on 32 bit architectures. On 64