how big should the byte array be in java me(j2me)

Keep getting the out of memory error when handling the image file in emulator(wtk) and device(e61i)
Just had a simple test and here is what I found:
The code is simple:
for(int i=1000;i<Integer.MAX_VALUE;i++){
byte[] buf = new byte[i];
and see when your program will crash. – Actually it won’t crash, as the OOME(out of memory error), is an Error rather RuntimeException, when the OOME is thrown, the program just go on.

Let’s see the result:
In wtk2.5.2 emulator: the size cannot beyond “2003765” byte(for comparison: we can reserve byte array of size  Integer.MAX_INTEGER/40 – 53687091 in standard version on my laptop).
In e61i: not instrumented yet. My guess is maybe much smaller, as I had experience that OOME thrown when the image size is only 300k, what different is: the byte array CAN take up to that size, however error happened when handling the image(when trying to createImage from byte array).
I followed this thread and the guys found that 400k bytes is the limit on nokia6681.

Another depressing result.

Comments are closed.