15

I'm getting "external allocation too large for this process" errors in my app. Lots of these at once:

11-16 10:56:59.230: ERROR/dalvikvm-heap(2875): 1303680-byte external allocation too large for this process.
11-16 10:56:59.230: ERROR/GraphicsJNI(2875): VM won't let us allocate 1303680 bytes
11-16 10:56:59.230: ERROR/dalvikvm-heap(2875): 1536000-byte external allocation too large for this process.
11-16 10:56:59.230: ERROR/GraphicsJNI(2875): VM won't let us allocate 1536000 bytes

It appears that they are produced while the layout is being rendered, after loading large bitmaps. The errors, however, are not produced while the bitmap is being decoded.

How can I debug these errors? Any additional pointers?

hpique
  • 119,096
  • 131
  • 338
  • 476
  • 1
    The framework will often capture views onscreen into temporary bitmaps for drawing performance. It looks like your app is pushing right up against its memory limit already and this bumps it over. Take a look at the other suggestions for limiting your app's memory usage. – adamp Nov 16 '10 at 16:16
  • @adamp Very interesting. Is this behavior documented somewhere? – hpique Nov 16 '10 at 17:29
  • Yes. See the various methods on the View class related to drawing caches. It's public API that apps can make use of as well. – adamp Nov 17 '10 at 06:01

2 Answers2

4

If you're using threads, then the debugger might be the source of the problem. If you run the app under the debugger, then any threads created will still be retained by the debugger, even when they're finished running. This leads to memory errors that won't occur when the app is running without the debugger.

http://code.google.com/p/android/issues/detail?id=7979

ThomasW
  • 16,981
  • 4
  • 79
  • 106
4

adamp's comment was the answer in my particular case:

The framework will often capture views onscreen into temporary bitmaps for drawing performance. It looks like your app is pushing right up against its memory limit already and this bumps it over. Take a look at the other suggestions for limiting your app's memory usage.

hpique
  • 119,096
  • 131
  • 338
  • 476