Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package org.github.jamm;
import java.lang.instrument.Instrumentation;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.Callable;
public class MemoryMeter {
private static Instrumentation instrumentation;
public static void premain(String options, Instrumentation inst) {
MemoryMeter.instrumentation = inst;
}
public static boolean hasInstrumentation() {
return instrumentation != null;
}
public static enum Guess {
/* If instrumentation is not available, error when measuring */
NEVER,
/* If instrumentation is available, use it, otherwise guess the size using predefined specifications */
FALLBACK_SPEC,
/* If instrumentation is available, use it, otherwise guess the size using sun.misc.Unsafe */
FALLBACK_UNSAFE,
/* If instrumentation is available, use it, otherwise guess the size using sun.misc.Unsafe; if that is unavailable,
* guess using predefined specifications.*/
FALLBACK_BEST,
/* Always guess the size of measured objects using predefined specifications*/
ALWAYS_SPEC,
/* Always guess the size of measured objects using sun.misc.Unsafe */
ALWAYS_UNSAFE
}
private final Callable> trackerProvider;
private final boolean includeFullBufferSize;
private final Guess guess;
public MemoryMeter() {
this(new Callable>() {
public Set