I have a spring webflux application with java 17, spring boot 3.3.3 and log4j2 with following JVM configs.
-XX:+UseG1GC
-XX:+UnlockExperimentalVMOptions
-XX:G1HeapRegionSize=1
-XX:G1ReservePercent=10
-XX:+DisableExplicitGC
-XX:MaxGCPauseMillis=200
-XX:InitiatingHeapOccupancyPercent=45
-XX:G1NewSizePercent=25
-XX:G1MaxNewSizePercent=30
-XX:TargetSurvivorRatio=25
-Xms1250m -Xmx1250m
—add-reads=jdk.jfr=ALL-UNNAMED
CPU config
Limits:
Cpu: 1500m
Memory: 2800Mi
Requests:
Cpu: 200m
Memory: 1800Mi
When I ran a perf test with 20 TPS for 2 days continously. At the start of the test heap utilization was at 45% then during the test for 3 days avg heap utilization increased gradually and one point it reached nearly 80-85% at the 3rd day which triggered major GC 3 times.
When I took the Heap dump could see Log4j Logger had nearly 3078102 instance and occupied Nearly 100 MB and 1 instance of Log4jLoggerFactory is occupies 180 MB.
From the Logger reference when I opened Path to GC reference could see one application class referrence which holds multiple logger instance reference.
Does this indicatie that particular application class is not releasing logger instance? In that application class I am printing a pojo in info mode.
Other than these 2 classes all other application classes are occupies very less memory not sure this is a memort leak if so how to find what is the cause of the memory leak.
org.apache.logging.slf4j.Log4jLogger
ororg.apache.logging.log4j.core.Logger
? Both are memoized so there should only be as many loggers as the number of logger names you request. Traditionally logger names follow class names, but you could generate unique logger names somewhere.