Two Freespace Systems

db4o comes with three freespace systems:

You can configure db4o to use either of these by calling

.NET: configuration.Freespace().UseRamSystem()

or

.NET: configuration.Freespace().UseBTreeSystem()

or

.NET: configuration.Freespace().UseIndexSystem()

This call should be made before you open the database for the first time

By default db4o uses RAM freespace management system. The information about free slots is loaded into memory on opening a database file and discarded on closing it. This system is quite fast, but it has its downside:

  1. Higher RAM usage during operation.
  2. Loss of freespace upon abnormal termination. That is done for security reasons and freespace can be reclaimed using defragmentation.

RAM-based freespace management is a good performance solution, but it can be insufficient for the systems with limited RAM resources and high probability of abnormal system termination (power failure on mobile devices).

In order to meet the requirements of such environments you can use new b-Tree-based freespace management system. It solves the problems of RAM-based system:

  1. RAM usage is kept at the minimum.
  2. No freespace is lost on abnormal system termination (database file won't grow unnecessarily).

How it works?:

b-Tree-based freespace system can show poorer performance compared to RAM-based system, as it needs to access the file to write updated freespace information.

However, b-Tree-based freespace system is fast enough, especially for mobile devices, where file access is not much slower than RAM-access, and ACID transactions together with low memory consumption are most valuable factors.

Index-based freespace system has similar to b-Tree characteristics, but poorer performance and is used for legacy reasons.