The question every language answers
Heap memory has to be released, and every language picks one of three answers.
Manual. The programmer calls free. Fast and predictable, and the source of the defect classes that dominate security reporting: use-after-free, double free, leaks. About 70% of the CVEs Microsoft assigned between 2006 and 2018 were memory safety issues, according to work by Matt Miller of the Microsoft Security Response Center presented in 2019, and Google has reported a comparable proportion for Chromium.
Garbage collection. A runtime determines when nothing references a value and reclaims it. Safe and convenient, at the cost of a runtime, unpredictable pauses, and memory overhead.
Ownership. Determine at compile time where each value's life ends, and insert the free there. No runtime, no pauses, and no manual calls.
The third is Rust's answer, and the entire language design follows from making it work. The cost is not paid at runtime; it is paid by the programmer, in the form of a compiler that rejects programs the other two would accept.

