I have a Spring Boot REST service that moves files from a folder into a ZIP archive every minute and upload the archive to another service. My service keeps a map of zipped files and zip name using Cache2K and HSQLDB. Another application uses the service to register the created files and later asks for the name of the zip in which the files was located.
The service is running on Windows Server 2019 Standard 32GB RAM with starting parameters
java -Xms512M -Xmx512M -XX:MaxMetaSpaceSize=128MB -XX:NativeMemoryTracking=detail
result of jcmd 1234 VM.native_memory
after 1min of running: total=1122461KB, commited=728301KB, task manager shows used=534MB
after week of running: total=1137792KB, commited=749376KB, but task manager shows used=8GB
Why is used/reserved memory so high?
Fight recorder do not shows any problems, GC runs well. I tried updating Oracle Java 8 to OpenJDK 11, updating Spring Boot to newer version, nothing helps. Memory consume growing seems to be linear.
Cacheentries? If your entries never expire theCachewill hold a reference to your entries forever and therefore the GC will never free this memory.Files.newDirectoryStream()orFiles.find(). Use learn.microsoft.com/en-us/sysinternals/downloads/… to see which files your process holds. If it's all the zip files or anything else unexpected, there's your leak. Also,-XX:NativeMemoryTracking=datailshould bedetail, you have a typo in yours.Files.newDirectoryStream()andFiles.walkwithout try-with-resources in my code. Code fixed and handles ocsilating about 730-750. Thanks very much.