O'Reilly logo

Advanced Mac OS X Programming: The Big Nerd Ranch Guide by Mark Dalrymple

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required