@Kvi
Your issue is available heap memory. This is restricted by Android and varies between devices. As soon as you try to use more than allowed you will get this memory error.
You can monitor how much memory your app is using and how much it is allowed to use. The following sketch shows how…
final Runtime runtime = Runtime.getRuntime();
int fontSize ;
ArrayList <TestObject> arrayList ;
void setup() {
fullScreen();
arrayList = new ArrayList<TestObject>() ;
fontSize = width/16 ;
textSize(fontSize);
textAlign(CENTER, CENTER) ;
}
void draw() {
background(0);
fill(255);
text("heap size = " + runtime.maxMemory()/1048576 +" MB", 10, 0, width, fontSize) ;
text("allocated memory = " + runtime.totalMemory()/1048576 + " MB", 10, 2*fontSize, width, fontSize);
text("arrayList total = " + 10*arrayList.size() + " MB", 10, 4*fontSize, width, fontSize);
}
void mousePressed() {
arrayList.add(new TestObject()); //add 10MB
}
class TestObject {
byte[] testArray ;
TestObject(){
testArray = new byte[10*1048576]; //10MB
}
}
Keep tapping the screen … you will see the allocated memory increase to allow the adding of new objects … until you reach the max allowed!