title: objective c programmatically deallocate/release objects
body: <p>I'm working on an iPhone game and currently the game uses many <code>UIImageViews</code> to show space ships, bullets and other things. The game probably has 30-40 different subviews in the view controller and I've decided that I should probably programmatically add subviews when they are needed rather than starting the game with them in the hidden state and making them unhidden when needed (for performance issues) so here are my questions:</p>
  
  <p>(1) will there be a significant performance gain from adding subviews when needed?</p>
  
  <p>(2) how do I release a subview when ARC is enabled? Im trying to add the views (based on type) into an <code>NSMutableArray</code> when its created to hold it, and removing it from the array when I'm done using it, does removing it from the array deallocate that memory? </p>
  
  <p>heres the code (theres an <code>NSTimer</code> that runs the movement method every 0.03 seconds, and the get and set methods are on an "instance variable" <code>NSMutableArray</code>);</p>
  
  <pre><code>-(void)movement {
      if (shootButton3.isHighlighted) {
          NSMutableArray *array = [self getBulletArray];
          [self setarray:array];
      }
      [self shootBullet: [self getArray]];
  }
  
  -(NSMutableArray *)getBulletArray {
      UIImageView *bullet = [[UIImageView alloc] initWithFrame:CGRectMake(ship.center.x + 20, ship.center.y, 15, 3)];
      bullet.image = [UIImage imageNamed:@"bullet2.png"];
      bullet.hidden = NO;
      [self.view addSubview:bullet];
      NSMutableArray *array = [[NSMutableArray alloc] init];
      [array addObject:bullet];
      return array;
  }
  -(void)shootBullet: (NSMutableArray *)bulletArray {
  
      for (int i = 0; i &lt; [bulletArray count]; i++) {
          UIImageView *bullet = [bulletArray firstObject];
          bullet.center = CGPointMake(bullet.center.x + 4, bullet.center.y);
          if (bullet.center.x &gt; 500) {
              bullet.hidden = YES;
              [bulletArray removeObjectAtIndex:0];
          }
  
      }
  }
  -(void)setarray:(NSMutableArray *) array {
      bulletArray = array;
  }
  -(NSMutableArray *)getArray {
      return bulletArray;
  }
  </code></pre>