r/cpp • u/ASA911Ninja • Jan 03 '26
Are memory leaks that hard to solve?
I have been coding in cpp for the last year (not regularly) and don’t have any professional experience. Why are memory leaks so hard to solve? If we use some basic rules and practices we can avoid them completely. 1) Use smart pointers instead of raw pointers 2) Use RAII, Rule of 5/3/0
I might be missing something but I believe that these rules shouldn’t cause memory related issues (not talking about concurrency issues and data races)
95
Upvotes
View all comments
Show parent comment
14
u/the_poope Jan 03 '26
You can also have cyclic references and thus memory leaks in Rust. But memory leaks aren't a security issue, it just causes the program to crash when you run out of memory.