We have 10 spring boot applications which are running on ubuntu18 with 8GB RAM and Java 11.
We are running the apps using java garbage collector -XX:+UseSerialGC without restricting the heap space.
But after few days server memory fully consumed and server got hanged.
Do we need to restrict the heap memory if we are using garbage collector ?
I have tried with other garbage collectors also but nothing working except +UseSerialGC.
The UseSerialGC is "ok-ish" (not good!) but will be blocking. Use the parallel one at least. Check https://www.baeldung.com/jvm-garbage-collectors for the differences.
That said,a different garbage collector isn't going to help you much if you have a genuine memory leak. You should probably profile your applications to see which instances of objects are not being recycled by the GC.
Check this article for Spring Boot: https://medium.com/illegalarguments/how-to-find-memory-leaks-in-spring-boot-592faf11d571