public class ObjectMemoryProfiler
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static org.apache.log4j.Logger |
LOGGER
Used for logging.
|
Constructor and Description |
---|
ObjectMemoryProfiler()
Builds a profiler with a default filter that accepts everything
|
ObjectMemoryProfiler(ProfilingFilter filter)
Builds a profiler that uses a given filter for it's global filter
|
ObjectMemoryProfiler(ProfilingFilter filter,
boolean buildChildRelations)
Builds a profiler that uses a given filter and optionally builds children relations into the profiled results
|
Modifier and Type | Method and Description |
---|---|
void |
addFilter(java.lang.Class clazz,
ProfilingFilter filter)
Adds a filter to be used when a certain class is encountered
|
static ObjectMemoryProfiler |
buildProfilerFromFiles(java.lang.String directory)
Builds a profiler using profiles from a directory.
|
static ObjectMemoryProfiler |
buildProfilerFromFiles(java.lang.String directory,
boolean buildChildRelations)
Builds a profiler using profiles from a directory.
|
ObjectMemoryProfile |
deepMemoryUseOfObject(java.lang.Object object)
Gets the deep memory use of an object.
|
boolean |
getBuildChildRelations()
Gets whether child relations will be built from this profiler's profiles or not
|
java.util.Map<java.lang.Class,ProfilingFilter> |
getProfilingFilters()
Returns a copy of the filters that this profiler will use
|
ObjectMemoryProfile |
memoryUseOfObject(java.lang.Object object)
Gets the shallow memory use of an object.
|
void |
setBuildChildRelations(boolean buildChildRelations)
Sets whether or not child relations will be built for future profiling from this object
|
void |
setGlobalFilter(ProfilingFilter filter)
Sets the global filter used by this profiler.
|
java.lang.String |
toString() |
public ObjectMemoryProfiler()
public ObjectMemoryProfiler(ProfilingFilter filter)
filter
- The filter to use as a global filterpublic ObjectMemoryProfiler(@Nullable ProfilingFilter filter, boolean buildChildRelations)
filter
- The global filter to usebuildChildRelations
- True to build child relations from this profiler (uses more memory), false otherwise.
When true, a top-down view can be done, otherwise only a bottom-up view will be possiblepublic void setBuildChildRelations(boolean buildChildRelations)
buildChildRelations
- True to build child relations, false otherwise. See the constructor for detailspublic boolean getBuildChildRelations()
public void addFilter(java.lang.Class clazz, ProfilingFilter filter)
clazz
- The class to set a filter forfilter
- The filter to use for the given class@NotNull public ObjectMemoryProfile deepMemoryUseOfObject(@NotNull java.lang.Object object)
object
- The object to get the memory use of@NotNull public ObjectMemoryProfile memoryUseOfObject(@NotNull java.lang.Object object)
object
- The object to get memory use for@NotNull public java.util.Map<java.lang.Class,ProfilingFilter> getProfilingFilters()
@NotNull public static ObjectMemoryProfiler buildProfilerFromFiles(@NotNull java.lang.String directory)
directory
- The location of the directory containing the filters@NotNull public static ObjectMemoryProfiler buildProfilerFromFiles(@NotNull java.lang.String directory, boolean buildChildRelations)
directory
- The location of the directory containing the filtersbuildChildRelations
- True if child relations should be built when profiling from the newly created profilerpublic void setGlobalFilter(@Nullable ProfilingFilter filter)
filter
- The filter to use globally. If an open filter is desired, use a blacklist filter with nothing set@NotNull public java.lang.String toString()
toString
in class java.lang.Object