• flashgnash@lemm.ee
      link
      fedilink
      arrow-up
      1
      ·
      18 days ago

      Thought the whole point was that it forced you to handle memory properly and automatically released things when they go out of scope

      What kind of situation can cause a memory leak in rust

      • naonintendois@programming.dev
        link
        fedilink
        arrow-up
        1
        ·
        18 days ago

        You can have a memory leak when items are still in scope in some loop or when you have a reference count cycle. The latter happens with the Rc/Arc types in rust.

        An example for the former can be a web server that keeps track of every request it’s ever received in memory. You will eventually run out of memory. But you did not violate any memory rules (dangling pointer, etc.). Memory leaks can be caused by design issues.