Generating java source code
Erik van Oosten
e.vanoos... at chello.nl
Tue Feb 13 10:54:20 UTC 2007
Hi,
I am examining the use of ragel for parsing Edifact messages to java
beans. So I came across a message about a 64K limit of java arrays.
Well, unless I am missing something, this is simply not true. I just
wrote a little program to test it. With -Xms1024M -Xmx1024M as JVM
argument, the limit is somewhere between 234881023 (224M) and
251658239 (240M) items (I aborted the program, it was swapping too
much). With only 128M of memory, the limit is still a healthy
30955269 (29M) items.
Regards,
Erik.
public class ArrayTest {
private int getMaxArraySize(int minValue, int maxValue) {
int min = minValue;
int max = maxValue;
while (min < max) {
System.out.println(min + "\t\t" + max);
int halfway = min + ((max - min) >> 1);
try {
Object[] arr = new Object[halfway];
min = halfway;
} catch (Error e) {
max = halfway - 1;
}
}
return min;
}
public static void main(String[] args) {
ArrayTest at = new ArrayTest();
System.out.println(at.getMaxArraySize(0, Integer.MAX_VALUE));
}
}
More information about the ragel-users
mailing list