Merge pull request 'Add memory usage logging to ShutdownListener during application shutdown' (#34) from fix/addreqlogging into main

Reviewed-on: #34
This commit is contained in:
Jan Weber 2025-11-28 12:45:43 +00:00
commit 97bf4f8ae7

View file

@ -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();
} }