title: ios alloc-release
body: <p>My app is receiving memory warnings because it's asking for lot of memory. I try to release every allocation. However, sometimes I don't know how to do it.</p>
  
  <p>For example: I have two pairs of .h and .m file. One of them makes connections with a server and the other with local SQLite.</p>
  
  <p>Usually, the code which calls to a method from those files are like this:</p>
  
  <pre><code>-(NSMutableArray *) getRecentActivity{
      LocalStorageController *local = [[LocalStorageController alloc]init];
      return [local getRecentActivity];
  }
  </code></pre>
  
  <p>getRecentActivity returns a NSMutableArray.</p>
  
  <p>Well, in that piece of code we can see that I am allocating memory for the LocalStorageController but I never call to the release method so, I suppose, the more I call that function, the more memory I will be allocating.</p>
  
  <p>If I call autorelease after init, it will crash.</p>
  
  <p>Moreover, usually, I use this other kind of code:</p>
  
  <pre><code>    ServerConnection *serv = [[ServerConnection alloc]init];
      NSMutableArray list = [serv getMyListOfContacts];
  </code></pre>
  
  <p>Which uses ASIHTTPRequest and, if I call <code>[serv release];</code> after the second line, the app crashes with EXC_BAD_ACCESS pointing to a line in ASIHTTPRequest library.</p>
  
  <p>How is suppose to manage this situation?</p>
  
  <p>Thank you very much!</p>