@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 static ThreadMXBean |
THREAD_MBEAN |
BARRIER_FOR_SIZE_IN_LOG| Constructor and Description |
|---|
GCInspector(IApexThreadDumper apexThreadDumper) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
addShutdownHook()
Deprecated.
|
protected void |
adjustWithReference(com.google.common.util.concurrent.AtomicLongMap<String> currentHeapToAdjust,
Map<? extends String,? extends Long> reference) |
void |
afterPropertiesSet() |
protected void |
appendCPU(StringBuilder sb) |
protected void |
appendCurrentGCDuration(StringBuilder sb,
com.sun.management.GarbageCollectionNotificationInfo info,
long duration) |
protected void |
appendDetailsAboutMove(StringBuilder sb,
long totalAfterMinusbefore,
long totalHeapUsedBefore) |
protected void |
appendDirectMemoryAndThreads(StringBuilder sb) |
protected void |
appendHeap(StringBuilder sb,
long totalHeapUsedAfter) |
protected void |
appendMovedMemory(StringBuilder sb,
String key,
MemoryUsage before,
MemoryUsage after) |
protected void |
appendPercentage(StringBuilder sb,
long numerator,
long denominator) |
static void |
appendSize(StringBuilder sb,
long size) |
void |
clearAllocatedHeapReference() |
protected long |
computeDurationMs(com.sun.management.GarbageCollectionNotificationInfo info) |
static <T> Map<T,String> |
convertByteValueToString(Map<T,Long> threadNameToAllocatedHeap) |
void |
destroy()
Clean the MBean registration.
|
protected BufferPoolMXBean |
directMemoryStatus() |
protected void |
doLog(com.sun.management.GarbageCollectionNotificationInfo info) |
protected void |
executeDuringShutdown() |
String |
getAllThreads(boolean withoutMonitors) |
String |
getAllThreadsSmart(boolean withoutMonitors) |
String |
getAndLogCurrentMemoryStatus() |
protected Map<? extends String,? extends Long> |
getAndSetByThreadRef(Map<? extends String,? extends Long> immutableCurrentHeapByThread) |
protected String |
getCurrentMemoryStatusMessage() |
String |
getHeapHistogram() |
static String |
getHeapHistogramAsString(int nbRows) |
Date |
getLatestThreadDump() |
long |
getMarksweepDurationMillisForHeapHistogram() |
long |
getMarksweepDurationMillisForThreadDump() |
protected static long |
getMaxDirectMemorySize() |
protected long |
getMaxHeap() |
long |
getMaxHeapGbForHeapHistogram() |
static String |
getNiceBytes(long size) |
protected NavigableSet<String> |
getSortedGCKeys(com.sun.management.GarbageCollectionNotificationInfo info) |
Map<String,String> |
getThreadGroupsToAllocatedHeapNiceString() |
protected Map<? extends String,? extends Long> |
getThreadNameToAllocatedHeap() |
Map<String,String> |
getThreadNameToAllocatedHeapNiceString() |
protected long |
getUsedHeap() |
protected com.google.common.util.concurrent.AtomicLongMap<String> |
groupThreadNames(Map<String,Long> threadNameToAllocatedHeap) |
void |
handleNotification(Notification notification,
Object handback) |
static boolean |
inUnitTest() |
protected boolean |
isFullGC(com.sun.management.GarbageCollectionNotificationInfo info) |
protected boolean |
isOverThreashold(long heapUsed,
long heapMax) |
protected void |
logIfMemoryOverCap() |
protected String |
makeGCMessage(com.sun.management.GarbageCollectionNotificationInfo info) |
void |
markNowAsAllocatedHeapReference() |
protected void |
onFullGC(com.sun.management.GarbageCollectionNotificationInfo info) |
protected void |
onMemoryBackUnderThreshold(long heapUsed,
long heapMax) |
protected void |
onOverHeapAlertSinceTooLong(org.joda.time.LocalDateTime overThresholdSince) |
protected void |
printHeapHistogram(int nbRows) |
protected void |
printSmartThreadDump() |
protected void |
printThreadDump() |
protected void |
removeNotificationListener() |
long |
saveHeapDump(String path,
boolean gzipped) |
void |
setMarksweepDurationMillisForHeapHistogram(long marksweepDurationMillisForHeapHistogram) |
void |
setMarksweepDurationMillisForThreadDump(long marksweepDurationMillisForThreadDump) |
void |
setMaxHeapGbForHeapHistogram(long maxHeapGbForHeapHistogram) |
static void |
streamHeapHistogram(OutputStream os,
int nbRows) |
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
public GCInspector(IApexThreadDumper apexThreadDumper)
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(com.sun.management.GarbageCollectionNotificationInfo info)
protected String makeGCMessage(com.sun.management.GarbageCollectionNotificationInfo info)
protected void appendMovedMemory(StringBuilder sb, String key, MemoryUsage before, MemoryUsage after)
protected NavigableSet<String> getSortedGCKeys(com.sun.management.GarbageCollectionNotificationInfo info)
protected void appendCurrentGCDuration(StringBuilder sb, com.sun.management.GarbageCollectionNotificationInfo info, long duration)
protected void appendHeap(StringBuilder sb, long totalHeapUsedAfter)
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 void appendDirectMemoryAndThreads(StringBuilder sb)
protected void appendPercentage(StringBuilder sb, long numerator, long denominator)
public static void appendSize(StringBuilder sb, long size)
public static String getNiceBytes(long size)
protected void doLog(com.sun.management.GarbageCollectionNotificationInfo info)
protected void onFullGC(com.sun.management.GarbageCollectionNotificationInfo 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(com.sun.management.GarbageCollectionNotificationInfo 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)
protected static long getMaxDirectMemorySize()
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 © 2017 Pivotal Software, Inc.. All rights reserved.