fusesource / leveldbjni

A Java Native Interface to LevelDB
BSD 3-Clause "New" or "Revised" License
536 stars 143 forks source link

Problem opening my leveldb database #49

Closed idar closed 10 years ago

idar commented 10 years ago

After using leveldb in my application for a few days now i started seeing this exception

Caused by: org.fusesource.leveldbjni.internal.NativeDB$DBException: IO error: /filarkiv/database/journal/ 000119.sst: Cannot allocate memory at org.fusesource.leveldbjni.internal.NativeDB.checkStatus(NativeDB.java:200) ~[leveldbjni-all-1. 8.jar:1.8] at org.fusesource.leveldbjni.internal.NativeIterator.checkStatus(NativeIterator.java:121) ~[level dbjni-all-1.8.jar:1.8] at org.fusesource.leveldbjni.internal.NativeIterator.next(NativeIterator.java:157) ~[leveldbjni-a ll-1.8.jar:1.8] at org.fusesource.leveldbjni.internal.JniDBIterator.next(JniDBIterator.java:100) ~[leveldbjni-all -1.8.jar:1.8]

I have 1 leveldb running with 100mb cache and the files take 32mb ram. I have 7 other leveldb stores which i open on demand every other hour with 10mb cache. Its seems random which leveldb gets this error.

Heap has around 1gb of ram left.

If i restart the computer, start the java process it might work for a while.

I open leveldb like this:

if (db == null) {
            Options options = new Options();
            options.cacheSize(cacheSizeInMB * 1048576); // MB cache
            options.createIfMissing(true);
            if(!new File(directory).exists())
                new File(directory).mkdirs();
            try {
                db = factory.open(new File(directory), options);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

close it like this: "db.close();"

idar commented 10 years ago

I also get this on stderr, then java crashes instantly.

  what():  std::bad_alloc
idar commented 10 years ago

Seems to have fixed itself. Deleted my m2 repo.

idar commented 10 years ago

Error came back today.

davsclaus commented 10 years ago

The first error is something about cannot allocate memory.