Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory leak of LevelDB snapshots in RpcNep5Tracker plugin. #57

Merged
merged 1 commit into from
Mar 13, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions RpcNep5Tracker/RpcNep5Tracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class RpcNep5Tracker : Plugin, IPersistencePlugin, IRpcPlugin
private DataCache<Nep5TransferKey, Nep5Transfer> _transfersReceived;
private WriteBatch _writeBatch;
private bool _shouldTrackHistory;
private Neo.IO.Data.LevelDB.Snapshot _levelDbSnapshot;

public override void Configure()
{
Expand All @@ -44,8 +45,9 @@ public override void Configure()
private void ResetBatch()
{
_writeBatch = new WriteBatch();
var balancesSnapshot = _db.GetSnapshot();
ReadOptions dbOptions = new ReadOptions { FillCache = false, Snapshot = balancesSnapshot };
_levelDbSnapshot?.Dispose();
_levelDbSnapshot = _db.GetSnapshot();
ReadOptions dbOptions = new ReadOptions { FillCache = false, Snapshot = _levelDbSnapshot };
_balances = new DbCache<Nep5BalanceKey, Nep5Balance>(_db, dbOptions, _writeBatch, Nep5BalancePrefix);
if (_shouldTrackHistory)
{
Expand Down