According to the source code and documentation, io.github.classgraph.ScanResult must be closed to avoid memory and file leaks.
I identified a large memory leak that apparently after adding geode-log4j. Surprisingly the cause ended up being an instance of ScanResult which is used by the management code to search the classpath for user classes that implement geode functions or gfsh commands.
Geode currently depends on ClassGraph version 4.0.6, but the library is up to version 4.8.52 (averaging around a dozen releases per month).
JVM bytes in use by io.github.classgraph after closing all ScanResult instances:
- Before geode-log4j with ClassGraph 4.0.6: 20,488 bytes
- Before geode-log4j with ClassGraph 4.8.52: 1,056 bytes
- After geode-log4j with ClassGraph 4.0.6: 56,753,008 bytes
- After geode-log4j with ClassGraph 4.8.52: 1,056 bytes
Given the above results of my testing, I believe we need to keep this dependency up-to-date and upgrade to 4.8.52.
More detailed notes below:
Git version shas that were tested:
Java process memory sizes:
Biggest objects - Dominators comparison (retained size in bytes):
Class and package comparison (retained size in bytes):
Class loader comparison:
Reachability comparison (retained size in bytes):