Ask HN: How to avoid memory leaks in C? - philonoist
======
TheChaplain
Write code that is easy to maintain/read, make sure you understand the API:s
and free allocated resources. Also learn how to use Valgrind, it is a
remarkable tool really.

~~~
flukus
> Also learn how to use Valgrind, it is a remarkable tool really

Seconded. Valgrind + unit tests + an incremental build can give you some
really fast feedback on memory leaks and other issues. Just yesterday it
showed us some errors in some "memory safe" c++ corner cases too.

------
blacksqr
"Writing Bug-free C Code"

[https://www.duckware.com/bugfreec/index.html](https://www.duckware.com/bugfreec/index.html)

