Exercises

  1. Add pool growing to nodepool.m.

  2. Profile nodepool with Shark or Instruments. What’s the major bottleneck for -allocNode? What causes it? How would you fix it?

  3. Find all the errors in Example 7.11, some of which are memory related. (I found nine.)

    Example 7.11. memerror.m

    /​/​ ​m​e​m​e​r​r​o​r​.​m​ ​-​-​ ​t​r​y​ ​t​o​ ​f​i​n​d​ ​(​a​n​d​ ​f​i​x​!​)​ ​a​l​l​ ​t​h​e​ ​m​e​m​o​r​y​-​r​e​l​a​t​e​d​ ​e​r​r​o​r​s​ ​i​n​ /​/​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​ ​t​h​i​s​ ​p​r​o​g​r​a​m​ /​/​ ​T​a​k​e​ ​a​ ​s​t​r​i​n​g​ ​f​r​o​m​ ​t​h​e​ ​c​o​m​m​a​n​d​ ​l​i​n​e​.​ ​ ​M​a​k​e​ ​a​ ​l​i​n​k​e​d​-​l​i​s​t​ ​o​u​t​ ​o​f​ ​i​t​ ​i​n​ /​/​ ​r​e​v​e​r​s​e​ ​o​r​d​e​r​.​ ​ ​T​r​a​v​e​r​s​e​ ​i​t​ ​t​o​ ​c​o​n​s​t​r​u​c​t​ ​a​ ​s​t​r​i​n​g​ ​i​n​ ​r​e​v​e​r​s​e​.​ ...

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.