Debugging Memory Problems

Errors in memory management cause a huge number of problems when programming in C and can lead to difficult-to-track-down bugs since the manifestation of a problem can happen long after the actual program error happened.

Common API issues

When malloc() cannot allocate memory, it returns NULL. Many programmers tend to ignore NULL results from malloc(). The conventional wisdom was that if memory really is exhausted, then the system is in some pretty serious trouble and is swapping heavily. In that case, it is just easier to crash and restart. Plus, it can be tedious to check the return value of malloc() all the time. In these days of systems with many gigabytes of RAM, it’s possible for an app to fill up its address space ...

Get Advanced Mac OS X Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.