0

I'm having a weird issue.

I've created an app which works fine on a Samsung Galaxy S2 (heap size 48MB) but when I test it on a Motorola Xoom (heap size also 48MB) it exits with an OutOfMemory error.

This is particularly strange since from what I can tell I'm only actually loading about 20MB of data into the heap.

The crash occurs at the same place every time, it's when I'm loading the dictionary file into a Vector (the app is a word-game, and the dictionary file that is being loaded is about 2MB and resides in the assets folder). The dictionary makes it about as far as the words starting with R and then gives up the ghost.

The Samsung is running Android 2.2 and the Xoom is running 4.0.3

Here's the code which loads the dictionary:

public class Dictionary {
    Vector words = new Vector();

    public Dictionary() {
    }

    public void loadWords(String dFile) {
        try {
            InputStream is = AndroidFileIO.assets.open(dFile);
            BufferedReader f = new BufferedReader(new InputStreamReader(is), 8192);
            String word = null;
            if (is != null) {
                while ((word = f.readLine()) != null) {
                    words.addElement(word.toUpperCase());
                }
            }
            is.close();
            f = null;
        } catch (Exception e) {
            System.err.println("Unable to read from " + dFile);
            // continue with empty dictionary
        }
    }

...and here's the LogCat output:

01-27 17:16:12.750: D/dalvikvm(9050): GC_FOR_ALLOC freed 63K, 4% free 6529K/6787K, paused 53ms
01-27 17:16:12.760: I/dalvikvm-heap(9050): Grow heap (frag case) to 8.383MB for 2048016-byte allocation
01-27 17:16:12.810: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 4% free 8529K/8839K, paused 2ms+8ms
01-27 17:16:12.870: D/dalvikvm(9050): GC_FOR_ALLOC freed 20K, 4% free 8543K/8839K, paused 25ms
01-27 17:16:12.890: I/dalvikvm-heap(9050): Grow heap (frag case) to 12.302MB for 4096016-byte allocation
01-27 17:16:12.940: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 3% free 12543K/12871K, paused 24ms
01-27 17:16:12.980: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 3% free 12543K/12871K, paused 3ms+3ms
01-27 17:16:13.350: D/libEGL(9050): loaded /system/lib/egl/libGLES_android.so
01-27 17:16:13.360: D/libEGL(9050): loaded /system/lib/egl/libEGL_tegra.so
01-27 17:16:13.390: D/libEGL(9050): loaded /system/lib/egl/libGLESv1_CM_tegra.so
01-27 17:16:13.400: D/libEGL(9050): loaded /system/lib/egl/libGLESv2_tegra.so
01-27 17:16:13.440: D/OpenGLRenderer(9050): Enabling debug mode 0
01-27 17:16:13.840: D/dalvikvm(9050): GC_FOR_ALLOC freed 11K, 1% free 14001K/14087K, paused 20ms
01-27 17:16:13.890: D/dalvikvm(9050): GC_CONCURRENT freed 1K, 1% free 16000K/16135K, paused 2ms+3ms
01-27 17:16:13.990: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 16001K/16135K, paused 19ms
01-27 17:16:14.000: I/dalvikvm-heap(9050): Grow heap (frag case) to 19.585MB for 4096016-byte allocation
01-27 17:16:14.060: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 20001K/20167K, paused 1ms+20ms
01-27 17:16:14.370: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 20001K/20167K, paused 17ms
01-27 17:16:14.380: I/dalvikvm-heap(9050): Grow heap (frag case) to 21.540MB for 2048016-byte allocation
01-27 17:16:14.420: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 22001K/22215K, paused 2ms+3ms
01-27 17:16:14.510: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 22001K/22215K, paused 17ms
01-27 17:16:14.520: I/dalvikvm-heap(9050): Grow heap (frag case) to 25.446MB for 4096016-byte allocation
01-27 17:16:14.540: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 1% free 26001K/26247K, paused 2ms+3ms
01-27 17:16:14.840: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 26001K/26247K, paused 20ms
01-27 17:16:14.840: I/dalvikvm-heap(9050): Grow heap (frag case) to 27.399MB for 2048016-byte allocation
01-27 17:16:14.870: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 28001K/28295K, paused 1ms+3ms
01-27 17:16:15.070: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 2% free 28389K/28743K, paused 20ms
01-27 17:16:15.080: I/dalvikvm-heap(9050): Grow heap (frag case) to 31.683MB for 4096016-byte allocation
01-27 17:16:15.130: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 32388K/32775K, paused 2ms+3ms
01-27 17:16:15.220: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 2% free 32390K/32775K, paused 19ms
01-27 17:16:15.220: I/dalvikvm-heap(9050): Grow heap (frag case) to 35.591MB for 4096016-byte allocation
01-27 17:16:15.260: D/dalvikvm(9050): GC_CONCURRENT freed <1K, 2% free 36390K/36807K, paused 1ms+4ms
01-27 17:16:16.510: D/dalvikvm(9050): GC_CONCURRENT freed 554K, 2% free 37925K/38535K, paused 2ms+5ms
01-27 17:16:16.940: D/dalvikvm(9050): GC_CONCURRENT freed 1047K, 3% free 38914K/40071K, paused 2ms+6ms
01-27 17:16:17.150: D/dalvikvm(9050): GC_CONCURRENT freed 982K, 3% free 39891K/41031K, paused 2ms+8ms
01-27 17:16:17.430: D/dalvikvm(9050): GC_CONCURRENT freed 1012K, 3% free 40876K/42055K, paused 2ms+8ms
01-27 17:16:17.770: D/dalvikvm(9050): GC_FOR_ALLOC freed 997K, 3% free 41820K/43015K, paused 65ms
01-27 17:16:18.100: D/dalvikvm(9050): GC_FOR_ALLOC freed 989K, 3% free 42757K/43975K, paused 75ms
01-27 17:16:18.480: D/dalvikvm(9050): GC_FOR_ALLOC freed 950K, 3% free 43636K/44871K, paused 81ms
01-27 17:16:18.780: D/dalvikvm(9050): GC_FOR_ALLOC freed 940K, 3% free 44525K/45767K, paused 84ms
01-27 17:16:19.130: D/dalvikvm(9050): GC_FOR_ALLOC freed 946K, 3% free 45421K/46663K, paused 94ms
01-27 17:16:19.410: D/dalvikvm(9050): GC_FOR_ALLOC freed 905K, 3% free 46303K/47559K, paused 99ms
01-27 17:16:19.770: I/dalvikvm-heap(9050): Clamp target GC heap from 48.105MB to 48.000MB
01-27 17:16:19.770: D/dalvikvm(9050): GC_FOR_ALLOC freed 897K, 3% free 47157K/48455K, paused 106ms
01-27 17:16:20.050: I/dalvikvm-heap(9050): Clamp target GC heap from 48.855MB to 48.000MB
01-27 17:16:20.050: D/dalvikvm(9050): GC_FOR_ALLOC freed 793K, 3% free 47924K/49159K, paused 112ms
01-27 17:16:20.220: I/dalvikvm-heap(9050): Clamp target GC heap from 49.239MB to 48.000MB
01-27 17:16:20.220: D/dalvikvm(9050): GC_FOR_ALLOC freed 396K, 2% free 48317K/49159K, paused 112ms
01-27 17:16:20.360: I/dalvikvm-heap(9050): Clamp target GC heap from 49.439MB to 48.000MB
01-27 17:16:20.360: D/dalvikvm(9050): GC_FOR_ALLOC freed 206K, 2% free 48523K/49159K, paused 109ms
01-27 17:16:20.480: I/dalvikvm-heap(9050): Clamp target GC heap from 49.541MB to 48.000MB
01-27 17:16:20.480: D/dalvikvm(9050): GC_FOR_ALLOC freed 104K, 2% free 48626K/49159K, paused 107ms
01-27 17:16:20.600: I/dalvikvm-heap(9050): Clamp target GC heap from 49.592MB to 48.000MB
01-27 17:16:20.600: D/dalvikvm(9050): GC_FOR_ALLOC freed 53K, 1% free 48679K/49159K, paused 111ms
01-27 17:16:20.720: I/dalvikvm-heap(9050): Clamp target GC heap from 49.618MB to 48.000MB
01-27 17:16:20.730: D/dalvikvm(9050): GC_FOR_ALLOC freed 26K, 1% free 48706K/49159K, paused 117ms
01-27 17:16:20.830: I/dalvikvm-heap(9050): Clamp target GC heap from 49.628MB to 48.000MB
01-27 17:16:20.830: D/dalvikvm(9050): GC_FOR_ALLOC freed 11K, 1% free 48717K/49159K, paused 105ms
01-27 17:16:20.950: I/dalvikvm-heap(9050): Clamp target GC heap from 49.631MB to 48.000MB
01-27 17:16:20.950: D/dalvikvm(9050): GC_FOR_ALLOC freed 2K, 1% free 48719K/49159K, paused 114ms
01-27 17:16:21.060: I/dalvikvm-heap(9050): Clamp target GC heap from 49.633MB to 48.000MB
01-27 17:16:21.060: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 1% free 48721K/49159K, paused 112ms
01-27 17:16:21.170: I/dalvikvm-heap(9050): Clamp target GC heap from 49.636MB to 48.000MB
01-27 17:16:21.170: D/dalvikvm(9050): GC_FOR_ALLOC freed 3K, 1% free 48724K/49159K, paused 108ms
01-27 17:16:21.170: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 176-byte allocation
01-27 17:16:21.300: I/dalvikvm-heap(9050): Clamp target GC heap from 49.628MB to 48.000MB
01-27 17:16:21.300: D/dalvikvm(9050): GC_BEFORE_OOM freed 9K, 1% free 48715K/49159K, paused 127ms
01-27 17:16:21.410: I/dalvikvm-heap(9050): Clamp target GC heap from 49.635MB to 48.000MB
01-27 17:16:21.410: D/dalvikvm(9050): GC_FOR_ALLOC freed 8K, 1% free 48722K/49159K, paused 108ms
01-27 17:16:21.520: I/dalvikvm-heap(9050): Clamp target GC heap from 49.639MB to 48.000MB
01-27 17:16:21.520: D/dalvikvm(9050): GC_FOR_ALLOC freed 4K, 1% free 48727K/49159K, paused 109ms
01-27 17:16:21.620: I/dalvikvm-heap(9050): Clamp target GC heap from 49.641MB to 48.000MB
01-27 17:16:21.620: D/dalvikvm(9050): GC_FOR_ALLOC freed 2K, 1% free 48729K/49159K, paused 109ms
01-27 17:16:21.730: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.730: D/dalvikvm(9050): GC_FOR_ALLOC freed 1K, 1% free 48730K/49159K, paused 105ms
01-27 17:16:21.840: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.840: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 110ms
01-27 17:16:21.950: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:21.950: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.050: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.050: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.050: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 44-byte allocation
01-27 17:16:22.170: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.170: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 119ms
01-27 17:16:22.170: E/dalvikvm-heap(9050): Out of memory on a 44-byte allocation.
01-27 17:16:22.170: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.170: I/dalvikvm(9050):   | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.170: I/dalvikvm(9050):   | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.180: I/dalvikvm(9050):   | schedstat=( 6918844000 741848000 1627 ) utm=668 stm=23 core=0
01-27 17:16:22.180: I/dalvikvm(9050):   at java.lang.String.<init>(String.java:~432)
01-27 17:16:22.180: I/dalvikvm(9050):   at java.io.BufferedReader.readLine(BufferedReader.java:363)
01-27 17:16:22.180: I/dalvikvm(9050):   at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.180: I/dalvikvm(9050):   at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.180: I/dalvikvm(9050):   at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.180: I/dalvikvm(9050):   at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.180: I/dalvikvm(9050):   at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.280: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.280: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 107ms
01-27 17:16:22.280: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 72-byte allocation
01-27 17:16:22.400: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.400: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 118ms
01-27 17:16:22.400: E/dalvikvm-heap(9050): Out of memory on a 72-byte allocation.
01-27 17:16:22.400: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.400: I/dalvikvm(9050):   | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.400: I/dalvikvm(9050):   | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.400: I/dalvikvm(9050):   | schedstat=( 7142111000 746215000 1665 ) utm=690 stm=24 core=0
01-27 17:16:22.400: I/dalvikvm(9050):   at java.lang.Throwable.nativeFillInStackTrace(Native Method)
01-27 17:16:22.400: I/dalvikvm(9050):   at java.lang.Throwable.fillInStackTrace(Throwable.java:160)
01-27 17:16:22.400: I/dalvikvm(9050):   at java.lang.Throwable.<init>(Throwable.java:83)
01-27 17:16:22.400: I/dalvikvm(9050):   at java.lang.Error.<init>(Error.java:37)
01-27 17:16:22.400: I/dalvikvm(9050):   at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:35)
01-27 17:16:22.400: I/dalvikvm(9050):   at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:33)
01-27 17:16:22.400: I/dalvikvm(9050):   at java.lang.String.<init>(String.java:-1)
01-27 17:16:22.400: I/dalvikvm(9050):   at java.io.BufferedReader.readLine(BufferedReader.java:363)
01-27 17:16:22.400: I/dalvikvm(9050):   at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.400: I/dalvikvm(9050):   at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.400: I/dalvikvm(9050):   at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.400: I/dalvikvm(9050):   at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.400: I/dalvikvm(9050):   at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.410: W/dalvikvm(9050): Exception thrown (Ljava/lang/OutOfMemoryError;) while throwing internal exception (Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.510: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.510: D/dalvikvm(9050): GC_FOR_ALLOC freed <1K, 1% free 48730K/49159K, paused 106ms
01-27 17:16:22.510: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 54-byte allocation
01-27 17:16:22.630: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.630: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 122ms
01-27 17:16:22.630: E/dalvikvm-heap(9050): Out of memory on a 54-byte allocation.
01-27 17:16:22.630: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.630: I/dalvikvm(9050):   | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.630: I/dalvikvm(9050):   | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.630: I/dalvikvm(9050):   | schedstat=( 7366692000 753065000 1725 ) utm=709 stm=27 core=0
01-27 17:16:22.630: I/dalvikvm(9050):   at java.io.BufferedReader.readLine(BufferedReader.java:~422)
01-27 17:16:22.630: I/dalvikvm(9050):   at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.630: I/dalvikvm(9050):   at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.630: I/dalvikvm(9050):   at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.630: I/dalvikvm(9050):   at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.630: I/dalvikvm(9050):   at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.750: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.750: D/dalvikvm(9050): GC_FOR_ALLOC freed 0K, 1% free 48730K/49159K, paused 112ms
01-27 17:16:22.750: I/dalvikvm-heap(9050): Forcing collection of SoftReferences for 64-byte allocation
01-27 17:16:22.870: I/dalvikvm-heap(9050): Clamp target GC heap from 49.643MB to 48.000MB
01-27 17:16:22.870: D/dalvikvm(9050): GC_BEFORE_OOM freed 0K, 1% free 48730K/49159K, paused 122ms
01-27 17:16:22.870: E/dalvikvm-heap(9050): Out of memory on a 64-byte allocation.
01-27 17:16:22.870: I/dalvikvm(9050): "Thread-1489" prio=5 tid=13 RUNNABLE
01-27 17:16:22.870: I/dalvikvm(9050):   | group="main" sCount=0 dsCount=0 obj=0x417e7bd8 self=0x1a6a168
01-27 17:16:22.870: I/dalvikvm(9050):   | sysTid=9119 nice=0 sched=0/0 cgrp=default handle=27700176
01-27 17:16:22.870: I/dalvikvm(9050):   | schedstat=( 7590841000 762536000 1798 ) utm=731 stm=28 core=1
01-27 17:16:22.870: I/dalvikvm(9050):   at java.lang.Throwable.nativeFillInStackTrace(Native Method)
01-27 17:16:22.870: I/dalvikvm(9050):   at java.lang.Throwable.fillInStackTrace(Throwable.java:160)
01-27 17:16:22.870: I/dalvikvm(9050):   at java.lang.Throwable.<init>(Throwable.java:83)
01-27 17:16:22.870: I/dalvikvm(9050):   at java.lang.Error.<init>(Error.java:37)
01-27 17:16:22.870: I/dalvikvm(9050):   at java.lang.VirtualMachineError.<init>(VirtualMachineError.java:35)
01-27 17:16:22.870: I/dalvikvm(9050):   at java.lang.OutOfMemoryError.<init>(OutOfMemoryError.java:33)
01-27 17:16:22.870: I/dalvikvm(9050):   at java.io.BufferedReader.readLine(BufferedReader.java:-1)
01-27 17:16:22.870: I/dalvikvm(9050):   at com.kittykazoo.game.Dictionary.loadWords(Dictionary.java:22)
01-27 17:16:22.870: I/dalvikvm(9050):   at com.kittykazoo.gamecore.ScreenLoading.loadAssets(ScreenLoading.java:232)
01-27 17:16:22.870: I/dalvikvm(9050):   at com.kittykazoo.gamecore.ScreenLoading.update(ScreenLoading.java:64)
01-27 17:16:22.870: I/dalvikvm(9050):   at com.kittykazoo.framework.implementation.AndroidFastRenderView.run(AndroidFastRenderView.java:48)
01-27 17:16:22.870: I/dalvikvm(9050):   at java.lang.Thread.run(Thread.java:856)
01-27 17:16:22.870: W/dalvikvm(9050): Exception thrown (Ljava/lang/OutOfMemoryError;) while throwing internal exception (Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.870: W/dalvikvm(9050): Could not resolve class ref'ed in exception catch list (class index 1237, exception Ljava/lang/OutOfMemoryError;)
01-27 17:16:22.870: W/dalvikvm(9050): threadid=13: thread exiting with uncaught exception (group=0x40a391f8)
01-27 17:16:23.000: I/dalvikvm-heap(9050): Clamp target GC heap from 49.620MB to 48.000MB
01-27 17:16:23.000: D/dalvikvm(9050): GC_FOR_ALLOC freed 24K, 1% free 48706K/49159K, paused 128ms
01-27 17:16:23.000: E/AndroidRuntime(9050): FATAL EXCEPTION: Thread-1489
01-27 17:16:23.000: E/AndroidRuntime(9050): java.lang.OutOfMemoryError: [memory exhausted]
01-27 17:16:23.000: E/AndroidRuntime(9050):     at dalvik.system.NativeStart.main(Native Method)
01-27 17:18:00.910: I/Process(9050): Sending signal. PID: 9050 SIG: 9
trincot
  • 317,000
  • 35
  • 244
  • 286
1337ingDisorder
  • 821
  • 1
  • 6
  • 17
  • 1
    I don't think this is answerable. There's so many things that could cause one to take more memory than another- different version of the framework (even point revisions), different screen size, different dpi. I think you're just going to have to cut memory to make it run. – Gabe Sechan Jan 28 '15 at 01:29
  • Also, on loading only 20MB- your resources count against you as well, and they can be significant. – Gabe Sechan Jan 28 '15 at 01:30
  • use sqlite instead ... you don't need all "words" in memory for the whole time – Selvin Jan 28 '15 at 01:31
  • Well I guess that brings up a whole other question -- how is it that the really robust games which obviously use way more memory manage to run on devices like the xoom? I've downloaded and played games on there which have 1st-person 3D openGL as well as 2D games which have way more on-screen resources than the simple game I'm using. is there some trick to getting around the heap size and actually using the rest of the available memory in the device? It seems ridiculous that a device with 1GB ram is limiting me to just using 48MB – 1337ingDisorder Jan 28 '15 at 01:35
  • It may also be worth noting that while the error happens during the Dictionary load every time, I'm not convinced that its memory usage is the root of the problem. The dictionary is only 2MB. There are 10MB of MP3 files for background music on different game levels. If I comment out the loading of the MP3s the app still crashed with OOM when the dictionary is loaded. (But it loads perfectly every time on the Samsung with the same heaps size) – 1337ingDisorder Jan 28 '15 at 01:38

1 Answers1

0

Ended up finding a workaround by using android:largeHeap="true" in the AndroidManifest.xml file.

The AndroidDev documentation says that most applications shouldn't require that, but I don't feel the least bit guilty about it -- if they're going to limit each app to 48mb of RAM with a normal sized heap then I don't see how anyone is supposed to avoid using largeHeap for anything with more than a dozen small bitmaps and some background music.

1337ingDisorder
  • 821
  • 1
  • 6
  • 17