myDb.put(txn, key, data));
}
/* Recover the database, restart w/no evictor. */
long postCreateMemUsage = env.getMemoryUsage();
INList inlist = env.getEnvironmentImpl().getInMemoryINs();
long postCreateResidentNodes = inlist.getSize();
txn.commit();
myDb.close();
env.close();
myDb = initEnvAndDb(true, false, true, null);
/*
* Do two evictions, because the first eviction will only strip
* LNs. We need to actually evict BINS because preload only pulls in
* IN/BINs
*/
env.evictMemory(); // first eviction strips LNS.
env.evictMemory(); // second one will evict BINS
long postEvictMemUsage = env.getMemoryUsage();
inlist = env.getEnvironmentImpl().getInMemoryINs(); // re-get inList
long postEvictResidentNodes = inlist.getSize();
/* Now preload, but not up to the full size of the db */
long startTime = System.currentTimeMillis();
myDb.preload(0, 50);
long postPreloadMemUsage = env.getMemoryUsage();
long postPreloadResidentNodes = inlist.getSize();
/* Now iterate to get everything back into memory */
Cursor cursor = myDb.openCursor(null, null);
int count = 0;
OperationStatus status = cursor.getFirst(key, data, LockMode.DEFAULT);
while (status == OperationStatus.SUCCESS) {
count++;
status = cursor.getNext(key, data, LockMode.DEFAULT);
}
cursor.close();
long postIterationMemUsage = env.getMemoryUsage();
long postIterationResidentNodes = inlist.getSize();
if (DEBUG) {
System.out.println("postCreateMemUsage: " + postCreateMemUsage);
System.out.println("postEvictMemUsage: " + postEvictMemUsage);
System.out.println("postPreloadMemUsage: " + postPreloadMemUsage);