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

bug(cheatcodes): memory not deallocating after snapshot revertTo #8890

Open
1 of 2 tasks
Akbar30Bill opened this issue Sep 18, 2024 · 0 comments
Open
1 of 2 tasks

bug(cheatcodes): memory not deallocating after snapshot revertTo #8890

Akbar30Bill opened this issue Sep 18, 2024 · 0 comments
Labels
A-cheatcodes Area: cheatcodes T-bug Type: bug T-perf Type: performance T-to-investigate Type: to investigate

Comments

@Akbar30Bill
Copy link

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (a117fbf 2024-05-13T00:22:16.352837000Z)

What command(s) is the bug in?

forge script script/testSnapshot.sol

Operating System

macOS (Apple Silicon)

Describe the bug

Description:
As suggested in the Foundry book, the snapshots that are reverted should be deleted from memory. However, my script demonstrates that this is not the case, as the memory usage keeps growing.

I wrote a simple Forge script to illustrate this behavior. You can run the script and observe the increasing memory usage during execution:

pragma solidity ^0.8.25;

import {Script, console2} from "forge-std/Script.sol";

contract testSnapshot is Script {
    function run() public {
        for (uint256 i = 0; i < 1000000; i++) {
            console2.log("Snapshot number: ", i);
            uint256 snapshot = vm.snapshot();
            vm.revertTo(snapshot);
        }
    }

    function setUp() public {}
}

Expected Behavior:
After reverting to a snapshot, the memory allocated for that snapshot should be cleaned up or deallocated to prevent memory bloat.

Actual Behavior:
The memory usage continues to grow with each snapshot taken, even after it has been reverted.

Environment:

  • Solidity version: 0.8.25
  • Forge version: 0.2.0 (a117fbf 2024-05-13T00:22:16.352837000Z)

Steps to Reproduce:

  1. Run the provided script.
  2. Monitor the memory usage throughout the execution.

Please investigate this issue to confirm whether the snapshots are not being properly deallocated from memory.

@Akbar30Bill Akbar30Bill added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Sep 18, 2024
@zerosnacks zerosnacks added A-cheatcodes Area: cheatcodes and removed T-needs-triage Type: this issue needs to be labelled labels Sep 18, 2024
@zerosnacks zerosnacks changed the title Bug: Memory not deallocating after snapshot revert in Forge script bug(cheatcodes): memory not deallocating after snapshot revertTo Sep 18, 2024
@zerosnacks zerosnacks changed the title bug(cheatcodes): memory not deallocating after snapshot revertTo bug(cheatcodes): memory not deallocating after snapshot revertTo Sep 18, 2024
@zerosnacks zerosnacks added T-to-investigate Type: to investigate T-perf Type: performance labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-cheatcodes Area: cheatcodes T-bug Type: bug T-perf Type: performance T-to-investigate Type: to investigate
Projects
None yet
Development

No branches or pull requests

2 participants