Memory management in C++ is not automatic. You have to choose between unique_ptr and shared_ptr (among others), and getting it wrong results in use after free, which can be exploitable. Not using weak_ptr in the right place results in memory leaks. And so forth.