title: Why does Rust consider it safe to leak memory?
body: <p>According to <a href="https://doc.rust-lang.org/book/ch15-06-reference-cycles.html" rel="noreferrer">this chapter in the Rust Book</a>, it is possible to leak memory by creating a cycle of pointers:</p>
  
  <blockquote>
    <p>Rust’s memory safety guarantees make it difficult, but not impossible, to accidentally create memory that is never cleaned up (known as a <em>memory leak</em>). Preventing memory leaks entirely is not one of Rust’s guarantees in the same way that disallowing data races at compile time is, meaning memory leaks are memory safe in Rust. We can see that Rust allows memory leaks by using <code>Rc&lt;T&gt;</code> and <code>RefCell&lt;T&gt;</code>: it’s possible to create references where items refer to each other in a cycle. This creates memory leaks because the reference count of each item in the cycle will never reach 0, and the values will never be dropped.</p>
  </blockquote>
  
  <p>There exist alternatives like "weak pointers" that would allow you to create self-referential structures that could still be cleaned up when dropped. In fact, using <code>Weak&lt;T&gt;</code> is actually suggested later in that chapter.</p>
  
  <p>Why does Rust consider this safe? Why is this an instance where the language does not do anything to prevent 'bad programmer behaviour'?</p>