So I've been trying to get a memory intensive program to work, and kept running into memory errors. I've read the other threads, and they all talk about memory leaks, but I don't think that is the case here.
I created a button that allocates 1 megabyte of space, then displays the memory usage in megabytes (maxmem, totalmem, freemem). Initially i have (40, 5, 2), I press the button (40, 6, 2). I keep pressing the button and I get (40, 7, 2), (40, 8, 2), (40, 9, 2), then OutOfMemory. I would expect (40, 10, 2) and shouldn't get OutOfMemory until I hit (40, 40, 0), right?
int[][] hi = new int[100][];
int i = 0;
public void save(View view) {
hi[i] = new int[256*1024];
i++;
TextView tv1 = (TextView) findViewById(R.id.seekBar1Text);
System.gc();
tv1.setText("Memory is max " + Runtime.getRuntime().maxMemory()/1024/1024 + " total " + Runtime.getRuntime().totalMemory()/1024/1024 + " free " + Runtime.getRuntime().freeMemory()/1024/1024);
}