title: Huge Bitmaps causing ANR in android
body: <p>Here is the thing:</p>
  
  <ul>
  <li>I am working with Huge Bitmap [ 1024 X 1024 ]</li>
  <li>I need the BitMap data in ( RGB &amp; alpha ) format for pixel-wise manipulation; for this manipulation I am using native libraries</li>
  <li>Activity works well with [ 512 X 512 ] images ... But when I'm switching between the activities with similar task android crashes with the following trace</li>
  </ul>
  
  <p>The question is this:</p>
  
  <ul>
  <li>What am I doing wrong ? What should cause JiT resizing ? </li>
  <li>is there a way to load huge bitmaps .. ? if I use the application caching ; would it provide me with some benefit in this case ? If yes , then which memory would caching consume ? Mainly I am hitting the memory limits ... so I am trying to work around that...</li>
  </ul>
  
  <p>The trace:</p>
  
  <pre><code>03-22 14:21:05.240: I/dalvikvm(105): Jit: resizing JitTable from 8192 to 16384
  03-22 14:21:05.730: D/dalvikvm(196): GC_EXPLICIT freed 44K, 50% free 3130K/6151K,external 5368K/6703K, paused 713ms
  </code></pre>
  
  <p>Please Note : </p>
  
  <ul>
  <li>I'm currently running on API 10 [ there is no scope of using the API 11 or more ]</li>
  <li>I would not be able to use "android:largeHeap" option as well</li>
  <li>As I am using the native library I am hitting the 6 MB limit [ native memory ] , though I am having 32 MB Memory at my disposal...</li>
  </ul>
  
  <p><strong>UPDATE :</strong> [ ANR Trace  ]</p>
  
  <p>This ANR trace indicates KeyDispatchingTimedOut .. but I believe that's not the reason ... As upon clicking the "Menu" I'm switching to the another activity using Intent.. when this activity starts up it needs to calculate the "Background image" based on the "color array" using a native library... That's what takes long ...
  Note when the activity is started individually the same calculation occurs ...</p>
  
  <pre><code>E/ActivityManager(105): ANR in com.uc (com.uc/.UcMain)
  E/ActivityManager(105): Reason: keyDispatchingTimedOut
  E/ActivityManager(105): Load: 2.31 / 1.58 / 1.48
  E/ActivityManager(105): CPU usage from 29434ms to 1ms ago:
  E/ActivityManager(105):   97% 1737/com.uc: 97% user + 0.1% kernel / faults: 117 minor
  E/ActivityManager(105):   1.4% 73/akmd: 0% user + 1.4% kernel
  E/ActivityManager(105):   0.6% 105/system_server: 0.2% user + 0.3% kernel / faults: 9 minor
  </code></pre>