Giter Site home page Giter Site logo

basleijdekkers / ideajol Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stokito/ideajol

0.0 0.0 0.0 972 KB

IntellijIdea plugin for Java Object Layout (JOL) tool

Home Page: https://plugins.jetbrains.com/plugin/10953-java-object-layout

License: Apache License 2.0

Java 91.48% HTML 0.79% Kotlin 7.73%

ideajol's Introduction

Java Object Layout (JOL) plugin for IntelliJ Idea

JOL (Java Object Layout) is the tool to analyze object layout schemes in JVMs. For example, in HotSpot VM on 64x processor an empty string takes 40 bytes i.e. 24 bytes for String object itself + 16 bytes for an internal empty char array.

The plugin is a GUI for JOL and allows you to make an estimate how much memory the object takes.

Set a cursor into a class name and then press Code / Show Object Layout and you'll see a right panel with layout info.

screenshot.png

Thus, you can perform simplest but most efficient performance improvements. Just check your DTOs if they fit into 64 bytes of processor's cache line.

Only HotSpot VM is supported by JOL itself. The plugin supports only basic estimate of class layout in different VM modes i.e. the same as jol-cli estimates command. For more precise estimate use JOL library and estimate in run time on the real objects with GraphLayout:

import org.openjdk.jol.info.GraphLayout;
import java.util.HashMap;

public class JolTest {

    public static void main(String[] args) {
        HashMap<Object, Object> hashMap = new HashMap<>();
        hashMap.put("key", "value");
        System.out.println(GraphLayout.parseInstance(hashMap).toFootprint());
    }
}

Output will be like:

java.util.HashMap@7a79be86d footprint:
     COUNT       AVG       SUM   DESCRIPTION
         2        24        48   [B
         1        80        80   [Ljava.util.HashMap$Node;
         2        24        48   java.lang.String
         1        48        48   java.util.HashMap
         1        32        32   java.util.HashMap$Node
         7                 256   (total)

So you can see the full size including inner objects.

NOTE: Your app most likely will use the HotSpot with 64-bit VM, compressed references mode.

Installation

  • Using IDE built-in plugin system:

    Settings/Preferences > Plugins > Marketplace > Search for "JOL" > Install Plugin

  • Manually:

    Download the latest release and install it manually using Settings/Preferences > Plugins > โš™๏ธ > Install plugin from disk...

Inspection

The plugin provides an inspection to see most big classes. It's enabled by default. You can find the inspection by path Java | Memory | JOL: Class has too big memory footprint to configure or disable it.

Please rank the Plugin to make it more searchable.

Related projects

Heap dump *.hprof files analysers:


Plugin based on the IntelliJ Platform Plugin Template.

ideajol's People

Contributors

alllex avatar stokito avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.