title: Android out memory exception in map
body: <p>In my Android application I call server request every 10 seconds and update result in map with marker (creating bitmap, my marker has image &amp; text). I use <a href="https://github.com/googlemaps/android-maps-utils" rel="nofollow">Android map utils library</a> to create bitmap of my layout, this is working fine but my force close after some time with out of memory issue. </p>
  
  <pre><code>Note:
  My marker has image and text like a layout.
  its updates with dynamic result by every 10 seconds.
  </code></pre>
  
  <p>I have used two major class from the <a href="https://github.com/googlemaps/android-maps-utils" rel="nofollow">library</a></p>
  
  <p>1.<a href="https://github.com/googlemaps/android-maps-utils/blob/master/library/src/com/google/maps/android/ui/BubbleDrawable.java" rel="nofollow">BubbleDrawable</a>
  2.<a href="https://github.com/googlemaps/android-maps-utils/blob/master/library/src/com/google/maps/android/ui/IconGenerator.java" rel="nofollow">IconGenerator</a>, I have used this two classes to create bitmap of my layout.</p>
  
  <p>in my Map Activity I call the library every 10 seconds and refresh the map with custom markers.</p>
  
  <p>Code:</p>
  
  <pre><code>public class MainActivity extends Activity{
  
   private IconGenerator  icGen ;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
           icGen = new IconGenerator(this);
           serverResponse(); // this method call every 10 seconds
      } // onCreate ends here.
  
      void updateResult(String placeName){
           markerPin = googleMap.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(icGen.makeIcon(placeName))) // dynamic name 
               .position(markerLatLng).anchor(0.5f, 1.0f)); // I got out of memory exception here
          ....
          googleMap.addMarker(markerPin);     
      }
  
      void serverResponse(){
          JSONArray arr = new JSONArray(serverResponse);
          for(int i=0;i&lt;all.length();i++){
            name = arr.getJSONObject.getStrig(name);
            updateResult(name);
          }
      }
  }
  </code></pre>
  
  <p>I have no idea to resolve this problem, please help me.</p>