When objects are updated or deleted, the space previously occupied in the database file is marked as "free". The freespace management system takes care of this space by maintaining which places in the file are free.
By default the free space system keeps and maintains every bit of free space even the smallest ones. Very small blocks of storage are hard to reuse, because larger objects don't fit in. Therefore overtime more and more small blocks of free space are maintained. Maintaining these small free spaces can cost performance. Therefore you can configure the free-space system to discard small blocks. Then small blocks are not maintained as free space. On the downside these space is lost until the next defragmentation.
IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); // discard smaller than 256 bytes configuration.File.Freespace.DiscardSmallerThan(256);
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration() ' discard smaller than 256 bytes configuration.File.Freespace.DiscardSmallerThan(256)
When you use the memory free-space system the information of the free space locations is hold in memory. This is the fastest way to manage free space. However when the database is shut down abnormally, for example by a crash or power off, the free space information is lost. The space only can be reclaimed by defragmentation. This is the default-setting used by db4o.
IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); configuration.File.Freespace.UseRamSystem();
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration() configuration.File.Freespace.UseRamSystem()
The B-tree free space system hold the information a B-tree which is stored on commits. Since the free space information is stored on disk, it is usually a slower then the memory free space system. However it doesn't loose the information on abnormal termination. Additionally the B-tree free space system uses less memory resources than the memory free space system.
IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); configuration.File.Freespace.UseBTreeSystem();
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration() configuration.File.Freespace.UseBTreeSystem()
When you delete a object in db4o the storage it consumed isn't deleted. Instead only the storage space is marked as free and can be reused. Therefore it's possible to read also the content of deleted objects. If you want to avoid that, you can specify a free-space filler. This filler is responsible to overwrite the free-space.
Note that this costs performance, since additional IO operations are performed.
IEmbeddedConfiguration configuration = Db4oEmbedded.NewConfiguration(); configuration.File.Freespace.FreespaceFiller(new MyFreeSpaceFiller());
Dim configuration As IEmbeddedConfiguration = Db4oEmbedded.NewConfiguration() configuration.File.Freespace.FreespaceFiller(New MyFreeSpaceFiller())