Add memory usage logging to ShutdownListener during application shutdown
This commit is contained in:
parent
15ff5fa9fa
commit
eb45c5b17b
1 changed files with 8 additions and 0 deletions
|
|
@ -14,6 +14,14 @@ public class ShutdownListener {
|
||||||
@EventListener
|
@EventListener
|
||||||
public void onShutdown(ContextClosedEvent event) {
|
public void onShutdown(ContextClosedEvent event) {
|
||||||
log.error("Application shutdown. Context: {}, Thread: {}", event.getApplicationContext(), Thread.currentThread().getName());
|
log.error("Application shutdown. Context: {}, Thread: {}", event.getApplicationContext(), Thread.currentThread().getName());
|
||||||
|
|
||||||
|
Runtime runtime = Runtime.getRuntime();
|
||||||
|
long usedMemory = (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024;
|
||||||
|
log.info("Memory: {} used, {} total, {} free, {} max ", usedMemory, runtime.totalMemory() / 1024 / 1024, runtime.freeMemory() / 1024 / 1024, runtime.maxMemory() / 1024 / 1024);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
log.error("Application shutdown. Context: {}, Thread: {}", event.getApplicationContext(), Thread.currentThread());
|
||||||
log.error("Thread stack dump:");
|
log.error("Thread stack dump:");
|
||||||
Thread.dumpStack();
|
Thread.dumpStack();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue