public class MemoryProfiler extends Object implements javassist.Translator
This memory profiler instruments all method entries and exists using javassist. At each exit, it reports the relative memory usage, the total memory usage, and the exit point of the current method. Call it like this:
./fiji --main-class fiji.MemoryProfiler fiji.Main
Since the memory profiling slows down execution dramatically due to the synchronous output to stderr, you may want to limit the classes to be instrumented by setting the environment variable MEMORY_PROFILE_ONLY to a space-delimited list of classes.
If you want to instrument any class handled by IJPatcher, you need to use the slightly more complicated command line:
./fiji -Dpatch.ij1=false \ --cp jars/javassist.jar --cp jars/ij1-patcher.jar \ --cp jars/ij.jar --main-class net.imagej.patcher.MemoryProfiler \ -- ij.ImageJ
I wrote this class to profile the sudden resource hunger of Fiji Build and figured that this class might come in handy in the future, or for others, or both.
Modifier and Type | Field and Description |
---|---|
protected static boolean |
debug |
protected Set<String> |
only |
protected static Runtime |
runtime |
Constructor and Description |
---|
MemoryProfiler() |
MemoryProfiler(Collection<String> only) |
MemoryProfiler(String only) |
Modifier and Type | Method and Description |
---|---|
static void |
gc() |
static long |
get() |
protected void |
handle(javassist.CtBehavior behavior) |
static void |
main(String[] args) |
void |
onLoad(javassist.ClassPool pool,
String classname) |
static void |
report(long memoryBefore) |
void |
start(javassist.ClassPool pool) |
protected static final boolean debug
protected static Runtime runtime
public MemoryProfiler()
public MemoryProfiler(String only)
public MemoryProfiler(Collection<String> only)
public void start(javassist.ClassPool pool) throws javassist.NotFoundException, javassist.CannotCompileException
start
in interface javassist.Translator
javassist.NotFoundException
javassist.CannotCompileException
public void onLoad(javassist.ClassPool pool, String classname) throws javassist.NotFoundException
onLoad
in interface javassist.Translator
javassist.NotFoundException
protected void handle(javassist.CtBehavior behavior)
public static long get()
public static void report(long memoryBefore)
public static void gc()
Copyright © 2014–2022 ImageJ. All rights reserved.