Question: 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.

Answer: 
Problem solved.

`Files.newDirectoryStream()` and `Files.walk` enclosed with `try-with-resources`.

Thanks [Petr Janeček](https://stackoverflow.com/users/1273080/petr-jane%C4%8Dek)

*P.S. after a week of service running, memory consumption is stable*
Try the `-XX:MaxDirectMemorySize` parameter if off-heap memory is used