Add pruneStore method

We set both data to null and call GC after persistence is done.
This commit is contained in:
chimp1984 2021-10-26 14:24:07 +02:00
parent 5a8a9e9be8
commit 5ccef962d0
No known key found for this signature in database
GPG key ID: 9801B4EC591F90E3

View file

@ -27,6 +27,7 @@ import bisq.network.p2p.storage.persistence.StoreService;
import bisq.common.config.Config; import bisq.common.config.Config;
import bisq.common.file.FileUtil; import bisq.common.file.FileUtil;
import bisq.common.persistence.PersistenceManager; import bisq.common.persistence.PersistenceManager;
import bisq.common.util.GcUtil;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
@ -92,15 +93,20 @@ public class DaoStateStorageService extends StoreService<DaoStateStore> {
new Thread(() -> { new Thread(() -> {
Thread.currentThread().setName("Serialize and write DaoState"); Thread.currentThread().setName("Serialize and write DaoState");
persistenceManager.persistNow(() -> { persistenceManager.persistNow(() -> {
// After we have written to disk we remove the the daoState in the store to avoid that it stays in // After we have written to disk we remove the daoState in the store to avoid that it stays in
// memory there until the next persist call. // memory there until the next persist call.
store.setDaoState(null); pruneStore();
completeHandler.run(); completeHandler.run();
}); });
}).start(); }).start();
} }
public void pruneStore() {
store.setDaoState(null);
store.setDaoStateHashChain(null);
GcUtil.maybeReleaseMemory();
}
public DaoState getPersistedBsqState() { public DaoState getPersistedBsqState() {
return store.getDaoState(); return store.getDaoState();
} }