2 minutes
A wannabe myth-buster
I’ve found an article about memory management in C/C++, one of the mysteries in software development. The author, Cameron Laird, tries to give both an introduction to the problem as well as to show up some ways to get through it. What starts of as a myth-busting article, soon gets down to reality. From the beginning, Cameron Laid makes clear that there is no silver bullet approach, for albeit several decades of attention to the memory management of C/C++ the problems could not be eradicated. After these introductory warnings, the author tries to give a categorization of the mishaps that happen. There is a code snippet for every mistake: memory leak, missing assignments, dangling pointers and array bound violations are all presented in a clear and concise way. The rest of the article concentrates on ways to avoid the common pitfalls: First and foremost he suggests diligence & discipline. This is not truly a method to address memory problems but a sound coding style helps overall readability and with some remarks one can keep track of memory usage. Static code checkers can go over the code on their own and probably find problems the developer didn’t thought of. It is an automated mechanism for code review, a 2nd pair of eyes if you like. The prerequisite for a static code check is an error and warning free compilation of the sources. The author points out correctly that reality is different and even nowadays most programmers simply don’t care. Finally, memory libraries and run time memory tools are discussed. Unfortunately, the article falls short on this topic only stating the inclination of the author towards the live tools. Conclusively, the article is fun to read but falls short in giving practicable advices or to serve as a starting point for further reading.