@ManagedResource public class GCInspector extends Object implements NotificationListener, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean, IGCInspector
| Modifier and Type | Field and Description |
|---|---|
protected IApexThreadDumper |
apexThreadDumper |
static float |
BETWEEN_MINUS_ONE_AND_ZERO |
static long |
DEFAULT_GCDURATION_MILLIS_INFO_LOG
Any time a GC lasts longer than this duration, we log details about the GC
|
static long |
DEFAULT_MARKSWEEP_MILLIS_HEAPHISTOGRAM |
static long |
DEFAULT_MARKSWEEP_MILLIS_THREADDUMP
If a MarkSweep GC lasts more than this duration, we log a ThreadDump
|
static long |
DEFAULT_MAX_HEAP_GB_HEAPHISTOGRAM |
protected AtomicLong |
firstGcNotZero
Remember the length of the first GC, which is used as heuristic to know if GC times are expressed in ms or ns
|
static Set<String> |
FULL_GC_NAMES |
protected long |
gcDurationMillisForInfoLog |
protected AtomicReference<org.joda.time.LocalDateTime> |
latestThreadDump |
protected static org.slf4j.Logger |
LOGGER |
protected long |
marksweepDurationMillisForHeapHistogram |
protected long |
marksweepDurationMillisForThreadDump |
protected static long |
MAX_FIRST_PAUSE_MS
If the first GC pause is bigger than this size, we expect GC pauses are expressed in NS
|
protected long |
maxHeapGbForHeapHistogram |
protected static MBeanServer |
MBEAN_SERVER |
protected static List<MemoryPoolMXBean> |
MEMORY_POOLS_MBEAN |
static int |
NS_TO_MS
Deprecated.
One should use TimeUnit.NANOSECONDS.toMillis(timeInNs)
|
protected static OperatingSystemMXBean |
OS_MBEAN |
protected AtomicLong |
targetMaxTotalMemory |
protected static ThreadMXBean |
THREAD_MBEAN |
BARRIER_FOR_SIZE_IN_LOG| Constructor and Description |
|---|
GCInspector()
Default constructor with nice default
|
GCInspector(IApexThreadDumper apexThreadDumper) |
protected static final org.slf4j.Logger LOGGER
protected final AtomicLong firstGcNotZero
protected static final long MAX_FIRST_PAUSE_MS
@Deprecated public static final int NS_TO_MS
public static final float BETWEEN_MINUS_ONE_AND_ZERO
public static final long DEFAULT_GCDURATION_MILLIS_INFO_LOG
protected long gcDurationMillisForInfoLog
public static final long DEFAULT_MARKSWEEP_MILLIS_THREADDUMP
protected long marksweepDurationMillisForThreadDump
public static final long DEFAULT_MARKSWEEP_MILLIS_HEAPHISTOGRAM
protected long marksweepDurationMillisForHeapHistogram
public static final long DEFAULT_MAX_HEAP_GB_HEAPHISTOGRAM
protected long maxHeapGbForHeapHistogram
protected static final MBeanServer MBEAN_SERVER
protected static final OperatingSystemMXBean OS_MBEAN
protected static final ThreadMXBean THREAD_MBEAN
protected static final List<MemoryPoolMXBean> MEMORY_POOLS_MBEAN
protected AtomicReference<org.joda.time.LocalDateTime> latestThreadDump
protected final IApexThreadDumper apexThreadDumper
protected final AtomicLong targetMaxTotalMemory
public GCInspector(IApexThreadDumper apexThreadDumper)
public GCInspector()
@ManagedAttribute public void setTargetMaxTotalMemory(String targetMax)
@ManagedAttribute public long getTargetMaxTotalMemory()
public void afterPropertiesSet()
throws MalformedObjectNameException,
InstanceNotFoundException
afterPropertiesSet in interface org.springframework.beans.factory.InitializingBeanMalformedObjectNameExceptionInstanceNotFoundException@Deprecated protected void addShutdownHook()
protected void executeDuringShutdown()
public static boolean inUnitTest()
public void destroy()
throws Exception
destroy in interface org.springframework.beans.factory.DisposableBeanExceptionprotected void removeNotificationListener()
throws MalformedObjectNameException,
ListenerNotFoundException
public void handleNotification(Notification notification, Object handback)
handleNotification in interface NotificationListenerprotected long computeDurationMs(IApexGarbageCollectionNotificationInfo info)
protected String makeGCMessage(IApexGarbageCollectionNotificationInfo info)
protected void appendMovedMemory(StringBuilder sb, String key, MemoryUsage before, MemoryUsage after)
protected NavigableSet<String> getSortedGCKeys(IApexGarbageCollectionNotificationInfo info)
protected void appendCurrentGCDuration(StringBuilder sb, IApexGarbageCollectionNotificationInfo info, long duration)
protected void appendHeap(StringBuilder sb, long totalHeapUsedAfter)
protected void appendNonHeap(StringBuilder sb, long nonHeapUsedAfter)
protected void appendDetailsAboutMove(StringBuilder sb, long totalAfterMinusbefore, long totalHeapUsedBefore)
protected Map<? extends String,? extends Long> getAndSetByThreadRef(Map<? extends String,? extends Long> immutableCurrentHeapByThread)
protected String getCurrentMemoryStatusMessage()
protected void appendCPU(StringBuilder sb)
protected long appendDirectMemoryAndThreads(StringBuilder sb)
protected void appendPercentage(StringBuilder sb, long numerator, long denominator)
public static void appendSize(StringBuilder sb, long size)
@Deprecated public static String getNiceBytes(long size)
protected void doLog(IApexGarbageCollectionNotificationInfo info)
protected void onFullGC(IApexGarbageCollectionNotificationInfo info)
protected void logIfMemoryOverCap()
protected boolean isOverThreashold(long heapUsed,
long heapMax)
protected long getUsedHeap()
protected long getMaxHeap()
protected void onMemoryBackUnderThreshold(long heapUsed,
long heapMax)
protected void onOverHeapAlertSinceTooLong(org.joda.time.LocalDateTime overThresholdSince)
protected boolean isFullGC(IApexGarbageCollectionNotificationInfo info)
protected void printThreadDump()
protected void printSmartThreadDump()
protected void printHeapHistogram(int nbRows)
public static String getHeapHistogramAsString(int nbRows)
public static void streamHeapHistogram(OutputStream os, int nbRows)
@Deprecated protected static long getMaxDirectMemorySize()
ApexForOracleJVMprotected static long getMemoryPerThread()
protected BufferPoolMXBean directMemoryStatus()
@ManagedAttribute public Date getLatestThreadDump()
@ManagedAttribute public void setMarksweepDurationMillisForThreadDump(long marksweepDurationMillisForThreadDump)
setMarksweepDurationMillisForThreadDump in interface IGCInspector@ManagedAttribute public long getMarksweepDurationMillisForThreadDump()
getMarksweepDurationMillisForThreadDump in interface IGCInspector@ManagedAttribute public void setMarksweepDurationMillisForHeapHistogram(long marksweepDurationMillisForHeapHistogram)
setMarksweepDurationMillisForHeapHistogram in interface IGCInspector@ManagedAttribute public long getMarksweepDurationMillisForHeapHistogram()
getMarksweepDurationMillisForHeapHistogram in interface IGCInspector@ManagedAttribute public void setMaxHeapGbForHeapHistogram(long maxHeapGbForHeapHistogram)
setMaxHeapGbForHeapHistogram in interface IGCInspector@ManagedAttribute public long getMaxHeapGbForHeapHistogram()
getMaxHeapGbForHeapHistogram in interface IGCInspector@ManagedOperation public void markNowAsAllocatedHeapReference()
markNowAsAllocatedHeapReference in interface IGCInspector@ManagedOperation public void clearAllocatedHeapReference()
clearAllocatedHeapReference in interface IGCInspectorprotected Map<? extends String,? extends Long> getThreadNameToAllocatedHeap()
@ManagedAttribute public Map<String,String> getThreadNameToAllocatedHeapNiceString()
getThreadNameToAllocatedHeapNiceString in interface IGCInspectorprotected void adjustWithReference(com.google.common.util.concurrent.AtomicLongMap<String> currentHeapToAdjust, Map<? extends String,? extends Long> reference)
@ManagedAttribute public Map<String,String> getThreadGroupsToAllocatedHeapNiceString()
getThreadGroupsToAllocatedHeapNiceString in interface IGCInspectorprotected com.google.common.util.concurrent.AtomicLongMap<String> groupThreadNames(Map<String,Long> threadNameToAllocatedHeap)
public static <T> Map<T,String> convertByteValueToString(Map<T,Long> threadNameToAllocatedHeap)
@ManagedOperation public String getAllThreads(boolean withoutMonitors)
getAllThreads in interface IGCInspectorwithoutMonitors - JConsole will set withoutMonitors = true by default@ManagedOperation public String getAllThreadsSmart(boolean withoutMonitors)
getAllThreadsSmart in interface IGCInspectorwithoutMonitors - JConsole will set withoutMonitors = true by default@ManagedOperation public String getHeapHistogram()
getHeapHistogram in interface IGCInspectorpublic long saveHeapDump(String path, boolean gzipped)
saveHeapDump in interface IGCInspector@ManagedOperation public String getAndLogCurrentMemoryStatus()
getAndLogCurrentMemoryStatus in interface IGCInspectorCopyright © 2014–2017 Pivotal Software, Inc.. All rights reserved.