There is an actuator to trigger creation of a heap dump https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java
I thought it would be natural to also provide an actuator to trigger a GC run, but it looks like there is none.
Is there a good reason that it is missing?
I might be oversimplifying things, but all the WebEndpoint would need to do is call System.gc();, right?
If you think such a feature is useful, I would be willing to provide a PR.
Comment From: wilkinsona
Why do you want to be able to trigger a GC? Within the context of a heap dump, the existing endpoint's live parameter can be used to determine whether the whole heap or only live, reachable objects are included in the dump.
Note that System.gc() provides no guarantees that it will actually do anything so I think the value of having an Actuator endpoint for it would be quite limited.
Comment From: MahatmaFatalError
Well, for debugging, which I normally would do with VisualVM for locally running apps, but for apps running in remote environments like cf or k8s connecting VisualVM is sometimes cumbersome if possible at all. Having an actuator would simplify things.
Comment From: philwebb
We've discussed this today and adding an actuator point for this isn't something we want to add ourselves. It should be possible for you to develop your own actuator endpoint if this is something you need for your application.
Comment From: MahatmaFatalError
OK, understood, but coming back to my initial message, I would be interested in your rationale
Comment From: philwebb
I would be interested in your rationale
Since we're a small team we generally try to focus our efforts on features that will have the broadest appeal. As Andy already noted, "System.gc() provides no guarantees that it will actually do anything" and as such we feel the development and maintenance of this feature would be best left to individuals who feel like they need it.