Handy Tricks

Sometimes you are running, and you get an error like this:

a​.​o​u​t​(​1​1​2​3​3​)​ ​m​a​l​l​o​c​:​ ​*​*​*​ ​e​r​r​o​r​ ​f​o​r​ ​o​b​j​e​c​t​ ​0​x​1​0​0​1​2​0​:​ ​d​o​u​b​l​e​ ​f​r​e​e​
*​*​*​ ​s​e​t​ ​a​ ​b​r​e​a​k​p​o​i​n​t​ ​i​n​ ​m​a​l​l​o​c​_​e​r​r​o​r​_​b​r​e​a​k​ ​t​o​ ​d​e​b​u​g​

Usually by the time you can react, your program has moved far past that. As suggested, you can set a breakpoint on malloc_error_break to catch the offending free().

Another even more common occurrence in Cocoa programming is this error:

2​0​1​0​-​0​1​-​2​0​ ​2​0​:​0​3​:​3​8​.​0​8​0​ ​b​a​d​m​e​s​s​a​g​e​[​1​1​3​0​3​:​1​0​b​]​ ​*​*​*​ ​-​[​N​S​C​F​A​r​r​a​y​ ​ ​ ​ ​f​r​o​b​u​l​a​t​e​:​]​:​ ​u​n​r​e​c​o​g​n​i​z​e​d​ ​s​e​l​e​c​t​o​r​ ​s​e​n​t​ ​t​o​ ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.