When you hit the /actuator/heapdump
endpoint:
A full GC (Garbage Collection) is often triggered before or during the heap dump process.
This is to ensure that the heap dump reflects the most accurate state of live objects.
The JVM tries to clean up as much as possible before writing the dump to reduce file size and improve clarity.
This GC can significantly reduce memory usage, especially if there was a lot of garbage (unreferenced objects) in memory.
The heap dump itself does not clear memory, but the GC that precedes it does.