Abstract


Achieve memory safety = Achieve absence of undefined behaviour

It can be perfectly safe to have a pointer to freed memory. The important thing is to not use that pointer again, like reading it or freeing it etc

Poor Memory Safety

Achieve Memory Safety

Rust

  • Ensure Memory Safety at compile time, reducing potential runtime errors without sacrificing speed

Java

  • Take care of memory management with a Garbage Collector during runtime, this comes with performance compromise

C++

  • Make use of Smart Pointers to automate the memory management during runtime
  • However, developers are still able to perform memory management directly. Developers need to follow best practices to minimise the chance of violating memory safety