문제

I am using spring-mongo in my webapp. When I undeploy my application in Tomcat7, there is a memory leak. I suspect that it might be the Mongo object that I didn't explicitly close. I would like to know what is the correct way (and location) to close it.

도움이 되었습니까?

해결책

How about something like this:

@Component
public class MongoDBManager {

  @Autowired
  Mongo mongo;

  @PreDestroy
  public void shutdown() {
    mongo.close();
  }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top