Guice + Tomcat potential memory leak

后端 未结 3 1578
轻奢々
轻奢々 2020-12-17 18:28

I have just started using Google Guice with my Tomcat webapp, and have noticed the following in the catalina.out file whenever the WAR file is undeployed:

May

3条回答
  •  天命终不由人
    2020-12-17 18:49

    This helped me to get rid of "SEVERE" log entry for com.google.inject.internal.InjectorImpl:

    injector = null;
    System.gc(); 
    

    Where injector was the result of Guice.createInjector(...modules...)

    I admit, it looks like I didn't read about bad habit of calling System.gc(), but it totally makes sense, since Guice uses weak references internally.

    P.S. Tomcat 8, Java 8, Guice 3.0

提交回复
热议问题