It has come to my attention that Android applications have a heap limit of 16MB. Normally this won't pose a problems to ordenary applications, but I have found that it isn't as hard as one would think to reach this limit, especially when you are doing resource intensive things like testing. When the heap size reaches above 16MB you will get an java.lang.OutOfMemoryError exeption.
It is posible to increase this limit, but it seem to require direct intervension into the the Android source. By defining a compile flag, CUSTOM_RUNTIME_HEAP_MAX one can set the parameter that defines the max heap size of dalvik. This flag will then be used by the AndroidRuntime::start method in the frameworks/base/core/jni/AndroidRuntime.cpp to define the -Xmx parmater that sets the max heap size of dalvik.
ifdef CUSTOM_RUNTIME_HEAP_MAX
#define __make_max_heap_opt(val) #val
#define _make_max_heap_opt(val) "-Xmx" __make_max_heap_opt(val)
opt.optionString = _make_max_heap_opt(CUSTOM_RUNTIME_HEAP_MAX);
#undef __make_max_heap_opt
#undef _make_max_heap_opt
#else
/* limit memory use to 16MB */
opt.optionString = "-Xmx16m";
#endif
So if you define CUSTOM_RUNTIME_HEAP_MAX with a value like "20m" you will have increased the maximum heap size to 20MB.