Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your leak is here:</p> <pre><code>self.currentCars = [[NSMutableArray alloc] init]; self.expiredCars = [[NSMutableArray alloc] init]; </code></pre> <p>Assuming that you declared property accessores like this:</p> <pre><code>@property(nonatomic, retain) NSMutableArray *currentCars; @property(nonatomic, retain) NSMutableArray *expiredCars; </code></pre> <p>In my opinion, the best way to find leaks (other than using Instruments) is to keep track of the retain count manually.</p> <p>If you were to do that with for example <code>currentCars</code>, you would find your leak easily. Here is what happens:</p> <pre><code>self.currentCars = [[NSMutableArray alloc] init]; // The 'init' makes the retain count 1. // 'self.currentCars = ..' translates to the setCurrentCars: method. // You probably did not implement that method yourself, // but by synthesizing your property it is automatically implemented like this: - (void)setCurrentCars:(NSMutableArray *)array { [array retain]; // Makes the retain count 2 [currentCars release]; currentCars = array; } // In your viewWillDisappear: method [currentCars release], currentCars = nil; // Makes the retain count 1 so the object is leaked. </code></pre> <p>The solution is simple. Use this:</p> <pre><code>NSMutableArray *tempMutableArray = [[NSMutableArray alloc] init]; self.currentCars = tempMutableArray; [tempMutableArray release]; </code></pre> <p>A little sidenote. You shouldn't release your objects in <code>viewWillDisappear:</code>. The recommended place to do that is <code>dealloc</code>. So your code would be:</p> <pre><code>- (void)dealloc { [currentCars release], currentCars = nil; [expiredCars release], expiredCars = nil; [super dealloc]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload