If you forget to deallocate heap memory, it will stick around FOREVER?
The title of this post a quote from Gjengset's Rust for Rustaceans page 6, with my own emphasis:
If you forget to deallocate heap memory, it will stick around forever, and your application will eventually eat up all the memory on your machine.
Does this mean even after the program ends?
A straightforward reading of the sentence would indicate so (but then, it would also indicate that it sticks around even if you shut down your computer, so it's obviously hyperbolic). But then what he goes on to say in the paragraph makes me think that by "forever" he means "for the life of the program."
However, there are some cases where you explicitly want to leak memory. For example, say you have a read- only configuration that the entire program should be able to access. You can allocate that on the heap and explicitly leak it with
Box::leakto get a'staticreference to it.
So to clarify: if we don't deallocate heap memory, will it outlive the program?