Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ktoso/sbt-jol
Don't guess JVM object sizes. Get them on a silver platter.
https://github.com/ktoso/sbt-jol
Last synced: 2 months ago
JSON representation
Don't guess JVM object sizes. Get them on a silver platter.
- Host: GitHub
- URL: https://github.com/ktoso/sbt-jol
- Owner: ktoso
- Created: 2015-09-22T15:03:12.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-14T13:45:52.000Z (about 4 years ago)
- Last Synced: 2024-10-25T06:07:52.161Z (3 months ago)
- Language: Scala
- Homepage:
- Size: 16.6 KB
- Stars: 87
- Watchers: 9
- Forks: 7
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sbt-jol
[ ![Download](https://api.bintray.com/packages/ktosopl/sbt-plugins/sbt-jol/images/download.svg) ](https://bintray.com/ktosopl/sbt-plugins/sbt-jol/_latestVersion)
Trivial way to inspect OpenJDK's [*Java Object Layout*](http://openjdk.java.net/projects/code-tools/jol/) of your Scala classes.
Get the latest via:
```
// project/plugins.sbt
addSbtPlugin("pl.project13.sbt" % "sbt-jol" % pluginVersionHere)
```
Which allows you to (note auto-completion works nicely):
```
> jol:internals example.Entry
[info] # Running 64-bit HotSpot VM.
[info] # Using compressed oop with 3-bit shift.
[info] # Using compressed klass with 3-bit shift.
[info] # WARNING | Compressed references base/shifts are guessed by the experiment!
[info] # WARNING | Therefore, computed addresses are just guesses, and ARE NOT RELIABLE.
[info] # WARNING | Make sure to attach Serviceability Agent to get the reliable addresses.
[info] # Objects are 8 bytes aligned.
[info] # Field sizes by type: 4, 1, 1, 2, 2, 4, 4, 8, 8 [bytes]
[info] # Array element sizes: 4, 1, 1, 2, 2, 4, 4, 8, 8 [bytes]
[info]
[info] VM fails to invoke the default constructor, falling back to class-only introspection.
[info]
[info] example.Entry object internals:
[info] OFFSET SIZE TYPE DESCRIPTION VALUE
[info] 0 12 (object header) N/A
[info] 12 4 int Entry.value N/A
[info] 16 4 String Entry.key N/A
[info] 20 4 (loss due to the next object alignment)
[info] Instance size: 24 bytes
[info] Space losses: 0 bytes internal + 4 bytes external = 4 bytes total
```
Currently uses jol `0.5`.Contribute!
-----------
Please note that this plugin is mostly developed on a "on demand" basis by and for myself, contributions are very (!) welcome
since I most likely will not focus much on it unless I need more features (and for now estimates and internal are all I needed).
License
-------
Apache v2