The defragmentation system uses db4o's transactional core to write the data to the new defragmented file. For large databases managing a long transaction can become an issue and can slow down the defragmentation. Therefore you can set a commit frequency. This means after the set number of processed objects the transaction is committed on the new file.
DefragmentConfig config = new DefragmentConfig("database.db4o"); config.objectCommitFrequency(10000); Defragment.defrag(config);