Introduction to Space Reclamation and Compaction

When a stream is replaced or deleted, the space it occupies is not immediately available for re-use by other streams.

There are two things you can do about this:

  • reclaim unused space; this makes it available for re-use by the store

  • compact; this makes unused space available for re-use by the relevant system pool; for example, the filing system in the case of file-based stores.

Space reclamation and compaction are only supported by the permanent file store, CPermanentFileStore, and are not supported by embedded or direct file stores. Because permanent file stores must maintain their integrity, even when a transaction fails, normal operations use a relatively conservative approach to update these stores without overwriting old data. Therefore, applications using permanent file stores must compact them regularly.

The task of both space reclamation and compaction can be approached in one of two general ways:

  • as a single, possibly long-running, job

  • incrementally, as a series of small steps, running either synchronously or asynchronously.

Related concepts