Stroustrup: Deal with memory leaks by writing code without any
Original: Bjarne Stroustrup: How do I deal with memory leaks? By writing code that doesn't have any.
Why This Matters
Shows C++ creator's emphasis on proactive memory management practices
C++ creator Bjarne Stroustrup addresses memory leak prevention in his FAQ, advocating for writing leak-free code rather than fixing leaks after they occur. The FAQ covers C++ style and technique questions.
Bjarne Stroustrup, creator of C++, maintains a comprehensive FAQ on C++ style and techniques on his personal website. When asked about dealing with memory leaks, his straightforward answer is to write code that doesn't have any leaks in the first place. The FAQ, last modified February 26, 2022, covers various C++ topics including memory management, classes, templates, and exceptions. Stroustrup notes that maintenance of this FAQ may become sporadic as he has contributed to the unified isocpp.org C++ FAQ maintained by The C++ Foundation. He also references the C++ Core Guidelines as a maintained resource for modern C++ usage.