Discarding Free Space

.NET: Db4oFactory.Configure().Freespace().DiscardSmallerThan(byteCount)

Configures the minimum size of free space slots in the database file that are to be reused.

2 extremes for byteCount value:

  • Integer.MAX_VALUE - discard all free slots for the best possible startup time. The downside: database files will necessarily grow faster
  • 0 - default setting, all freespace is reused. The downside: increased memory consumption and performance loss for maintenance of freespace lists in RAM 

Advantage

Allows fine-tuning of performance/size relation for your environment.

Effect

When objects are updated or deleted, the space previously occupied in the database file is marked as "free", so it can be reused. db4o maintains two lists in RAM, sorted by address and by size. Adjacent entries are merged. After a large number of updates or deletes have been executed, the lists can become large, causing RAM consumption and performance loss for maintenance. With this method you can specify an upper bound for the byte slot size to discard.

Alternate Strategies

Regular defragment will also keep the number of free space slots small. See:

.NET: Db4objetcs.Db4o.Defragment.Defragment

If defragment can be frequently run, it will also reclaim lost space and decrease the database file to the minimum size. Therefore #discardSmallerThan(maxValue) may be a good tuning mechanism for setups with frequent defragment runs.