I found a way to load huge textures, but only honeycomb (Android 3.x) is supported.
Honeycomb increases the memory size per application to 48MB using the standard heap (as opposed to 24MB and 32MB in previous Androids). But loading a 2048x2048 texture still crashed my app.
Here is the memory allocation (crashes when loading the large texture):
09-22 18:21:08.190: VERBOSE/Tosh(25398): debug.heap native: allocated 3.02MB of 3.04MB (0.01MB free)
09-22 18:21:08.190: VERBOSE/Tosh(25398): debug.memory: allocated: 22.00MB of 48.00MB (6.00MB free)
Then I made the following changes to increase the heap to Large:
In default.properties file, I changed the target to 'target=android-11'
In AndroidManifest.xml file, I added 'android:largeHeap="true"' to the Application tag.
Now that large 2048 texture loads with no problem.
09-22 18:23:14.980: VERBOSE/Tosh(25572): debug.heap native: allocated 3.02MB of 3.02MB (0.00MB free)
09-22 18:23:14.980: VERBOSE/Tosh(25572): debug.memory: allocated: 55.00MB of 256.00MB (22.00MB free)
256MB to play with! But your app won't be able to run on any phone, or at least until Icecream Sandwich phones come out (2012).
Here's the code to log the memory stats
public static void logHeap() {
Double allocated = new Double(Debug.getNativeHeapAllocatedSize())/new Double((1048576));
Double available = new Double(Debug.getNativeHeapSize())/1048576.0;
Double free = new Double(Debug.getNativeHeapFreeSize())/1048576.0;
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
df.setMinimumFractionDigits(2);
Log.d("Log", "debug. =================================");
Log.d("Log", "debug.heap native: allocated " + df.format(allocated) + "MB of " + df.format(available) + "MB (" + df.format(free) + "MB free)");
Log.d("Log", "debug.memory: allocated: " + df.format(new Double(Runtime.getRuntime().totalMemory()/1048576)) + "MB of " + df.format(new Double(Runtime.getRuntime().maxMemory()/1048576))+ "MB (" + df.format(new Double(Runtime.getRuntime().freeMemory()/1048576)) +"MB free)");
}