Memory leak using Mongo Java Connection

I built the MongoClient connection as follows:

public static synchronized MongoClient getInstance(String mongoDbUri) { try { // Standard URI format: mongodb://[dbuser: dbpassword@ ]host:port/dbname if( mongoClient == null ){ mongoClient = new MongoClient( new MongoClientURI(mongoDbUri)); } } catch (Exception e) { log.error( "Error mongo connection : ", e.getCause()); } return mongoClient; } 

For a period of time when several transactions are performed, I see that some memory eats up an application that is not freed.

When analyzing a bunch of beer dumps, that memory consumption was maximum with class

com.mongodb.internal.connection.PowerOfTwoBufferPool

The mongo client is trying to connect to the mongos instance. The application has three sets of replicas on three sides and one configuration server for storing metadata.

To add more details to this, I have a spring driven bean annotated with @ Component.There is an annotation with @PostConstruct for the bean in which the above method is called. In spring, the class we are inserting / updating / creating with Mongo Client.

Thanks.

+5
source share

All Articles