In most of the research about the memory leak caused by finalizer object, either in our code or in a dependent library, one should be overriding the finalize method. But in my whole project its nowhere used. (I am using Java8)
I am facing a memory issue, where for my service, as soon as I restart the service, the available memory starts reducing and within 7 days it is down by 95% with frequent warnings coming later on.
Above graph shows the available memory in Y axis, which one can see reduces. All peaks in above graph is for restart of service.
When I went through the heap dump in eclipse Mat, I see the following :
As it can be seen, almost all the space is taken by 1 object only i.e. java.lang.ref.Finalizer
but when I did a field Java search in my project, I don't see any code using the finalize() method.
And I have hit a dead end trying to find the memory leak. Is there any other reason which might be causing the issue.
First thing IMO is to try to understand where the
Finalizer
is coming from - check your libs and try to spot that! Maybe they even mention something on their README/docs?After that, have a look at this answer/question that can give you some insights. Also, it sounds to me something related to the GC. Since you mentioned java 8, you should be using the parallel GC (default one) which is not bad but you can try play with that, change GCs and see if any of the other options works better for you.