Full_Name: Hallvard B Furuseth Version: mdb.master 8eef7a4275eda8f2fa2e0d1e67c1d5cbcd91607e OS: Linux x86_64 URL: ftp://ftp.openldap.org/incoming/ Submission from: (NULL) (193.69.163.163) Submitted by: hallvard
mdb_drop() does not seem to return overflow pages to the freelist. Does not call cursor_del or anything, nor 'ovpages' loop like it has.
E.g. the enclosed program which writes some pages and then drops the DB shows 59 free of 62 useed pages with non-overflows, but just 3 free of 38-39 with overflows.
#include <lmdb.h> #include <assert.h> #include <stdio.h> #include <stdlib.h>
int main(void) { MDB_env *env; MDB_txn *txn; MDB_dbi dbi; int rc, sz, sum; # define DBPATH "test.mdb" # define E(e) ((void) (rc = (e)), assert(!rc)) for (sz = 1500; sz < 9000; sz *= 2) { MDB_val key = {sizeof(sum), &sum}, data = {sz, NULL}; printf("======== datasize %d ========\n", sz); fflush(NULL); remove(DBPATH); E(mdb_env_create(&env)); E(mdb_env_set_maxdbs(env, 1)); E(mdb_env_open(env, DBPATH, MDB_NOSUBDIR, 0666)); E(mdb_txn_begin(env, 0, 0, &txn)); { E(mdb_dbi_open(txn, "foo", MDB_CREATE, &dbi)); for (sum = 0; (sum += sz) < 100000; ) E(mdb_put(txn, dbi, &key, &data, MDB_RESERVE)); E(mdb_txn_commit(txn)); } E(mdb_txn_begin(env, 0, 0, &txn)); { E(mdb_drop(txn, dbi, 1)); E(mdb_txn_commit(txn)); } mdb_env_close(env); system("../mdb_stat -naef " DBPATH " | grep -v ': 0$'"); } return 0; }