title: Custom Marker performance iOS, crash with result "((null)) was false: Reached the max number of texture atlases, can not allocate more."
body: <p>I have integrated Google Maps in my application and also using Google Places API. After I am getting all the results from Google Places API(around 60), I am displaying them with the help of custom marker. The custom marker which I am making comprises of "Place Image" and "Place Name" because of which I have to first draw it in a UIView and then render it as a UIImage with the help of following function </p>
  
  <pre><code>- (UIImage *)imageFromView:(UIView *) view
  {
      if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
  
          UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, [[UIScreen mainScreen] scale]);
      } else {
          UIGraphicsBeginImageContext(view.frame.size);
      }
      [view.layer renderInContext: UIGraphicsGetCurrentContext()];
      UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
  
      return image;
  }
  </code></pre>
  
  <p>At first all the markers are rendered and drawn easily.</p>
  
  <p>Now I have a slider ranging from 100m to 5km, which acts as a search radius optimiser. As the slider will be moved(suppose to a value 2km), then all the markers are removed and only those markers whose distance from user location is less then slider value are drawn again. While I am testing the slider functionality, the application crashes saying</p>
  
  <blockquote>
    <p>((null)) was false: Reached the max number of texture atlases, can not allocate more.</p>
  </blockquote>
  
  <p>I am uploading screen shots for clear understanding of situation.
  Please help.</p>
  
  <p><a href="https://i.stack.imgur.com/WyA4I.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WyA4Im.png" alt="image when radius is 5km"></a></p>
  
  <p><a href="https://i.stack.imgur.com/She5r.png" rel="noreferrer"><img src="https://i.stack.imgur.com/She5rm.png" alt="image when radius is 2.4km"></a></p>
  
  <p><a href="https://i.stack.imgur.com/SNO53.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SNO53m.png" alt="image when radius is 1.7km"></a></p>
  
  <p>Also to mention, in the screens you will see green markers as well as blue markers. Blue markers are those which are closer to user location while green ones are far off by a particular distance. As the user location will change there are 2 cases:</p>
  
  <ol>
  <li>If it is approaching a green marker, then it will turn to a blue marker </li>
  <li>If it is going far from a blue marker, then it will turn to a green marker.</li>
  </ol>