-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Memory leak in forge vm.snapshot and vm.revertTo #6411
Comments
thanks for this, checking shortly.
there's not but we can certainly add a new cheatcode for that. do you want to try this? |
Thanks you for the prompt response. Yes please that would be very helpful |
oh I think I remember why we did this, it was just more convenient than the old behaviour but we def need a cheatcode to clean snapshots then cc @Evalir @maa105 foundry/crates/cheatcodes/spec/src/vm.rs Lines 412 to 416 in 388e181
so I think we want a new cheatcode and an implementation like revertTo that clears them: foundry/crates/cheatcodes/src/evm.rs Lines 327 to 341 in 388e181
perhaps even an additional cheatcode do you feel comfortable with giving this a try? doesn't have to be perfect, a draft with cheatcodes would be sufficient
docs also need to be updated |
Thanks. Ill give it a shot tomorrow |
Reverting the commit of #5487 improved the memory leak meaning the increase in memory over time decreased however there is still memory leak :/ |
hey @maa105 — yep, reverting #5487 should alleviate the problem, but this is not something we want to do—we have users who depend on the new behavior (and we should update the docs) as it's much more convenient to not have snapshots deleted unless specifically requested. The solution to this is what @mattsse proposed |
The PR is indeed very useful however it worsens the problem of memory leak. Is there a way to reset all memory usages inside the test. I.e. mid way inside a test id like to nuke all memory and return to the state when the test started. |
I measured the required mem usage and it is 8545MB on CircleCI at the moment. I'm not sure why upstream needs so much less. The high memory usage might be caused by foundry-rs/foundry#6411
I measured the required mem usage and it is 8545MB on CircleCI at the moment. I'm not sure why upstream needs so much less. The high memory usage might be caused by foundry-rs/foundry#6411
I measured the required mem usage and it is 8545MB on CircleCI at the moment. I'm not sure why upstream needs so much less. The high memory usage might be caused by foundry-rs/foundry#6411
Closed by #6548 |
Component
Forge
Have you ensured that all of these are up to date?
What version of Foundry are you on?
forge 0.2.0 (7b45265 2023-11-21T00:22:00.899582254Z)
What command(s) is the bug in?
forge test
Operating System
Linux
Describe the bug
We have a huge test case where we have 1000s of cases and each with lots of vm.snapshot and vm.revertTo calls. We noticed the memory consumption increases when time goes so we did a small test to confirm it
What this code does is create a snapshot and revert directly in a loop then sleep for 2.5 seconds. If you run this you'll see the memory usage increases every 2-3 seconds consistently.
While digging around, we noticed that in your documentation here you mentioned that reverting a snapshot deletes the snapshot and all subsequent ones. However, we also noticed that this PR seems to do the opposite. We suspect that the memory leak is related to this PR.
On the short term is there a way to delete/clean the snapshots?
The text was updated successfully, but these errors were encountered: