deephacks / lmdbjni

LMDB for Java
Apache License 2.0
204 stars 28 forks source link

Number of new connections is limited #64

Closed mlebull closed 8 years ago

mlebull commented 8 years ago

Hi, When opening a large number of connections we seem to be exhausting the connection limit, even though all previous connections have been closed. I managed to solve the issue by disposing of the callback when calling close() on the database:

org.fusesource.lmdbjni.Database

61 @Override 62 public void close() {
--- // If a callback exists then dispose of it first
--- if(callback != null){
--- callback.dispose();
--- }
---
63 if (self != 0) {
64 mdb_dbi_close(env.pointer(), self);
65 self = 0;
66 }
67 }

If this this change looks correct and you could incorporate it into the next build it would be much appreciated. Thanks

krisskross commented 8 years ago

What is this callback you are referring to? Do you use a custom comparator?

mlebull commented 8 years ago

Hi, the Callback is the one defined in the Database class, and it has no external access so I can't dispose of it myself. Yes, I am using a custom comparator, through database.setComparator()

krisskross commented 8 years ago

I referenced the wrong issue in the commit message. Please review 9a29e34bd297711acf050c7c6a70f3d9e00b3721.

mlebull commented 8 years ago

Thanks very much, that's great. I've re tested and everything is working as expected.

krisskross commented 8 years ago

No problem, thanks for reporting!