How do you manage memory manually in C++ to prevent memory leaks and dangling pointers in high-performance applications?