Class MemoryLogger
java.lang.Object
java.lang.Thread
org.apache.flink.runtime.taskmanager.MemoryLogger
- All Implemented Interfaces:
Runnable
A thread the periodically logs statistics about:
- Heap and non-heap memory usage
- Memory pools and pool usage
- Garbage collection times and counts
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler -
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY -
Constructor Summary
ConstructorsConstructorDescriptionMemoryLogger(org.slf4j.Logger logger, long interval, CompletableFuture<Void> monitored) Creates a new memory logger that logs in the given interval and lives until the given termination future completes. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetDirectMemoryStatsAsString(BufferPoolMXBean bufferPoolMxBean) Returns a String with the direct memory footprint.static StringGets the garbage collection statistics from the JVM.static StringgetMemoryPoolStatsAsString(List<MemoryPoolMXBean> poolBeans) Gets the memory pool statistics from the JVM.static StringgetMemoryUsageStatsAsString(MemoryMXBean memoryMXBean) Gets the memory footprint of the JVM in a string representation.voidrun()voidshutdown()static voidstartIfConfigured(org.slf4j.Logger logger, org.apache.flink.configuration.Configuration configuration, CompletableFuture<Void> taskManagerTerminationFuture) Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
Constructor Details
-
MemoryLogger
Creates a new memory logger that logs in the given interval and lives until the given termination future completes.- Parameters:
logger- The logger to use for outputting the memory statistics.interval- The interval in which the thread logs.monitored- termination future for the system to whose life the thread is bound. The thread terminates once the system terminates.
-
-
Method Details
-
startIfConfigured
public static void startIfConfigured(org.slf4j.Logger logger, org.apache.flink.configuration.Configuration configuration, CompletableFuture<Void> taskManagerTerminationFuture) -
shutdown
public void shutdown() -
run
public void run() -
getMemoryUsageStatsAsString
Gets the memory footprint of the JVM in a string representation.- Returns:
- A string describing how much heap memory and direct memory are allocated and used.
-
getDirectMemoryStatsAsString
Returns a String with the direct memory footprint.These stats are not part of the other memory beans.
- Parameters:
bufferPoolMxBean- The direct buffer pool bean ornullif none available.- Returns:
- A string with the count, total capacity, and used direct memory.
-
getMemoryPoolStatsAsString
Gets the memory pool statistics from the JVM.- Parameters:
poolBeans- The collection of memory pool beans.- Returns:
- A string denoting the names and sizes of the memory pools.
-
getGarbageCollectorStatsAsString
Gets the garbage collection statistics from the JVM.- Parameters:
gcMXBeans- The collection of garbage collector beans.- Returns:
- A string denoting the number of times and total elapsed time in garbage collection.
-