com.github.marschall.objectsize.InstanceHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of object-size Show documentation
Show all versions of object-size Show documentation
A tool compute object graph sizes in Java
The newest version!
package com.github.marschall.objectsize;
final class InstanceHolder {
static final ObjectSizeCalculator INSTANCE = getInstance();
private static ObjectSizeCalculator getInstance() {
try {
if (!JvmtiObjectSizeCalculator.isSupported()) {
return new UnsupportedObjectSizeCalculator();
}
} catch (LinkageError e) {
return new UnsupportedObjectSizeCalculator();
}
ObjectSizeCalculator calculator = new JvmtiObjectSizeCalculator();
if (JfrObjectSizeCalculator.isSupported()) {
calculator = new JfrObjectSizeCalculator(calculator);
}
return calculator;
}
}