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 leveldb file increase #1333

Closed
Closed
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
1 change: 1 addition & 0 deletions neo/SmartContract/ApplicationEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ public static ApplicationEngine Run(byte[] script, Snapshot snapshot,
ApplicationEngine engine = new ApplicationEngine(TriggerType.Application, container, snapshot, extraGAS, testMode);
engine.LoadScript(script);
engine.Execute();
engine.Dispose();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The engine should be disposed by the caller.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems most caller just call it one time without release, we need a way to fix it once for all.
(https://github.com/neo-project/neo-plugins/blob/29fee59944fb4ae3a9e8d644c3d334fd3df5b474/RpcNep5Tracker/RpcNep5Tracker.cs#L168)
Changing it in neo.dll could eliminate the hidden trouble.
Ortherwise, we need check all plugins who call it and refactor.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to access the object, why dispose it before using?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For most conditions, we just use the method to get the run results not engine itself.
Sometime the smartcontract may invoke needing more gas than the gas limit. If this happen when opening leveldb iterators, the engine interrupts and these iterators cannot close normally. Unless call engine "dispose" manually.
Seem gas limit interrupts may happen in many unpredictable situations, fix the hidden leak trouble here could nip in the bud.

return engine;
}

Expand Down