mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-22 14:42:37 +01:00
Add pruneStore method
We set both data to null and call GC after persistence is done.
This commit is contained in:
parent
5a8a9e9be8
commit
5ccef962d0
1 changed files with 9 additions and 3 deletions
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue