I am currently working with Java, MongoDB and several threads.
For each threads, I run MongoDB connection.
private Mongo m;
m = new Mongo();
I had a look to the memory usage with TOP and I saw multiple instances of MongoDB Jar
(call to library mongo-2.6.3.jar). I tried to destroy it after end of processing of each thread with :
m.close();
m = null;
System.gc();
But nothing instances are still in memory until my program is stopped.
Any ideas ? Thanks.
OK I have made some tests regarding the tutorial, but not very successful. In fact, I have :
public class process {
public static Mongo m;
public static DB db;
public process() {
m = new Mongo();
//for each database
threadDatabase thread = new threadDatabase(database);
thread.start();
}
}
public class threadDatabase extends Thread {
public threadDatabase (String database) {
this.database = database;
}
public void run() {
process.db.requestStart();
processDatabase(this.database);
process.db.requestDone();
}
private boolean processDatabase(String dbname) {
process.db = process.m.getDB(dbname);
//getting data on the dedicated database
}
}