title: Objective C / iOS: Memory release with ARC (memory leak)
body: <p>I am new to <code>iOS/Objective-C</code> and I do not understand the release of memory correctly.
  To test it, I created an empty <code>ARC</code> enabled iPhone-Project and created a very simple test class:</p>
  
  <pre><code>#import "MemTest.h"
  
  @implementation MemTest {
  
  }
  
  -(void) start {
      for (int i = 0; i &lt; 1500000; i++) {
          NSMutableString *myString = [NSMutableString string];
  
          // The appended string is 2000 characters long in the real test class.
          [myString appendString:@"12345678901234567890123456 &lt;very long&gt;"];
  
          if (i % 1000 == 0) {
              NSLog(@"i = %d", i);
          }
  
          myString = nil;
      }
  }
  
  @end
  </code></pre>
  
  <p>I simply start the test in the <code>AppDelegate</code>:</p>
  
  <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
      MemTest *test = [[MemTest alloc] init];
      [test start];
  
      ....
  }
  </code></pre>
  
  <p>The application (as expected) prints many nice numbers "i = xy" but the memory usage increases with every iteration and finally the application crashes:</p>
  
  <pre><code>....
  2012-12-06 20:17:40.193 MemTestApp[19250:11303] i = 930000
  2012-12-06 20:17:40.208 MemTestApp[19250:11303] i = 931000
  MemTestApp(19250,0xac63f2c0) malloc: *** mmap(size=16777216) failed (error code=12)
  *** error: can't allocate region
  *** set a breakpoint in malloc_error_break to debug
  </code></pre>
  
  <p>So my question is: Why is the memory usage growing at all?</p>
  
  <p>I thought by assigning nil, the memory should be released, when using <code>ARC</code>. What am I missing here?</p>