An uncommon but not unheard method around that (in services that have diurnal patterns) is to throw memory at it and collect once a day during the down time. You can take the server out of service, restart it, and put it back in service.
Fwiw, the JVM now has a noop garbage collector so this is easy enough to benchmark.
But it is easy to monitor with Java’s killer observability.
Lisp I Programmers Manual, 1960
https://www.softwarepreservation.org/projects/LISP/book/LISP...
Chapter 6.3, Page 95, The Free-Storage List and the Garbage Collector