title: memory problem with google map and overlays !
body: <p>I am drawing some overlays on google map. If i move around the map too much, I get this error :</p>
  
  <p>10-15 14:43:43.020: ERROR/dalvikvm-heap(299): 32768-byte external allocation too large for this process.
  10-15 14:43:43.020: ERROR/GraphicsJNI(299): VM won't let us allocate 32768 bytes
  10-15 14:43:43.260: ERROR/AndroidRuntime(299): FATAL EXCEPTION: main
  10-15 14:43:43.260: ERROR/AndroidRuntime(299): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
  10-15 14:43:43.260: ERROR/AndroidRuntime(299):     at android.graphics.Bitmap.nativeCreate(Native Method)
  10-15 14:43:43.260: ERROR/AndroidRuntime(299):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)</p>
  
  <p>In my heap, I can see that less than 30% has been used.</p>
  
  <p>Can anyone help me out ? Is there a way out ? Thanks.</p>
  
  <p>///////////////////////////////////////////////</p>
  
  <p>public void draw(Canvas canvas, MapView mapv, boolean shadow){</p>
  
  <pre><code>    BusLoc.myMapView.destroyDrawingCache ();
      super.draw(canvas, mapv, shadow);
  
      Paint mPaint = new Paint();
      mPaint.setDither(true);
      mPaint.setColor(Color.RED);
      mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
      mPaint.setStrokeJoin(Paint.Join.ROUND);
      mPaint.setStrokeCap(Paint.Cap.ROUND);
      mPaint.setStrokeWidth(2);
  
      /////////////////////////////get the lat/long info/////////////////////////////////////
  
      BusLoc.mapCenter= BusLoc.myMapView.getMapCenter();
      int latCenter = BusLoc.mapCenter.getLatitudeE6();
      int longCenter = BusLoc.mapCenter.getLongitudeE6();
      int latSpan = BusLoc.myMapView.getLatitudeSpan();
      int longSpan = BusLoc.myMapView.getLongitudeSpan();
      int latMax = latCenter + (latSpan / 2);
      int latMin = latCenter - (latSpan / 2);
      int longMax = longCenter + (longSpan / 2);
      int longMin = longCenter - (longSpan / 2);
  
      ///////////////////////////////////////////////////////////////////////////////////////
  
  
      Log.d("MyOverlay","OnDraw");
  
      int in=0;
      for(in=0;in&lt;ind-1;in++)
      {
          if (ah1[in][0] ==0 ||(ah1[in+1][0]==0)) break;
          if((ah1[in][0] !=0) &amp;&amp;(ah1[in+1][0]!=0))
          {
              GeoPoint gP1 = new GeoPoint((int)(ah1[in][0]*1e6),(int)(ah1[in][1]*1e6)); //lat,lng
              GeoPoint gP2 = new GeoPoint((int)(ah1[in+1][0]*1e6),(int)(ah1[in+1][1]*1e6));
  
  
  
              Point p1 = new Point();
              Point p2 = new Point();
  
              Path path = new Path();
  
              Projection projection = BusLoc.myMapView.getProjection();
              projection.toPixels(gP1, p1);
              projection.toPixels(gP2, p2);
  
              path.moveTo(p2.x, p2.y);
              path.lineTo(p1.x,p1.y);
  
              if((((ah1[in][0]&lt;=latMax)&amp;&amp;(ah1[in][0]&gt;=latMin))&amp;&amp;((ah1[in][1]&lt;=longMax)&amp;&amp;(ah1[in][1]&gt;=longMin))) || (((ah1[in+1][0]&lt;=latMax)&amp;&amp;(ah1[in+1][0]&gt;=latMin))&amp;&amp;((ah1[in+1][1]&lt;=longMax)&amp;&amp;(ah1[in+1][1]&gt;=longMin))) )
              {
                  canvas.drawPath(path, mPaint);
              }
  
              Log.d("MyOverlay","drawn: "+gP1.toString()+":"+gP2.toString());
          }
      }
     // BusLoc.myMapView.destroyDrawingCache ();
  }
  </code></pre>