IdeaJol
IdeaJol copied to clipboard
Intellij plugin that shows an object layout in memory to help optimize it. Uses OpenJDK JOL tool
https://twitter.com/inponomarev/status/1328007656884342785
Other languages can be almost easily supported. So why not to do this? For C language it's almost clear and straightforward. Except of unions and inlined structs. Golang object layout:...
We can show gaps as red row, long fields as yellow, show cache line limit or something like that - to make it more visualizable.
Complete IDE freeze when typing source code and a "superclass recursion" is typed (see example below) and one would right-click -> Show Object Layout. Happened while testing for #29. However...
We use only few classes from jol-core so probably we can strip unused classes. This can be done on build or we can created more lightweight jol artifact.
https://shipilev.net/jvm/anatomy-quarks/24-object-alignment/ Now we have 8 and 16 bit aligment and we need to add 32, 64 and 128 bit aligments. I hope that more aligments not needed. Since there is...
NPE
``` java.lang.NullPointerException at org.openjdk.jol.info.ClassData.fieldsFor(ClassData.java:256) at org.openjdk.jol.info.ClassData.ownFields(ClassData.java:221) at org.openjdk.jol.layouters.HotSpotLayouter.layout(HotSpotLayouter.java:138) at com.github.stokito.IdeaJol.inspection.JolInspection.checkClass(JolInspection.java:50) at com.intellij.codeInspection.AbstractBaseUastLocalInspectionTool$1.visitClass(AbstractBaseUastLocalInspectionTool.java:75) at org.jetbrains.uast.UClass$DefaultImpls.accept(UClass.kt:71) at org.jetbrains.uast.java.AbstractJavaUClass.accept(JavaUClass.kt:23) at com.intellij.uast.UastHintedVisitorAdapter.visitElement(UastHintedVisitorAdapter.kt:21) at com.intellij.psi.impl.source.PsiClassImpl.accept(PsiClassImpl.java:472) at com.intellij.codeInspection.InspectionEngine.acceptElements(InspectionEngine.java:75) ```
This plugin is useless because it shows a layout of class itself while real size of object may vary because of inner objects. So we need a support of `GraphLayout.parseIncance()`...
The plugin can provide some inspections but I'm not sure which one. I have the only one idea: to inspect object which layout is bigger than a cache line i.e....