X
Xiaolei Li
hi, got a weird out of memory error here that i can't figure out.
here's the code:
System.out.println("free: " + Runtime.getRuntime().freeMemory());
char[] big2 = new char[2034640181];
System.out.println("free: " + Runtime.getRuntime().freeMemory());
when i run that, i get:
[xli10@luna test]$ java -d64 -Xms6g -Xmx6g Test
free: 6379219712
Exception in thread "main" java.lang.OutOfMemoryError
so the VM has enough memory. top reports that i have 19G free. i also
ran the following code:
System.out.println("free: " + Runtime.getRuntime().freeMemory());
char[] big = new char[1034640181];
System.out.println("free: " + Runtime.getRuntime().freeMemory());
char[] big2 = new char[1034640181];
System.out.println("free: " + Runtime.getRuntime().freeMemory());
and i get:
[xli10@luna test]$ java -d64 -Xms6g -Xmx6g Test
free: 6379219712
free: 4309939168
free: 2240658784
[xli10@luna test]$
this completes successfully even though it needed more memory overall
than the first program. is there something tricky about allocating
large chunks of memory at one time? here's my java version info.
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
this is running on:
SunOS luna 5.8 Generic_117350-04 sun4u sparc SUNW,Sun-Fire-880
thank you very much.
here's the code:
System.out.println("free: " + Runtime.getRuntime().freeMemory());
char[] big2 = new char[2034640181];
System.out.println("free: " + Runtime.getRuntime().freeMemory());
when i run that, i get:
[xli10@luna test]$ java -d64 -Xms6g -Xmx6g Test
free: 6379219712
Exception in thread "main" java.lang.OutOfMemoryError
so the VM has enough memory. top reports that i have 19G free. i also
ran the following code:
System.out.println("free: " + Runtime.getRuntime().freeMemory());
char[] big = new char[1034640181];
System.out.println("free: " + Runtime.getRuntime().freeMemory());
char[] big2 = new char[1034640181];
System.out.println("free: " + Runtime.getRuntime().freeMemory());
and i get:
[xli10@luna test]$ java -d64 -Xms6g -Xmx6g Test
free: 6379219712
free: 4309939168
free: 2240658784
[xli10@luna test]$
this completes successfully even though it needed more memory overall
than the first program. is there something tricky about allocating
large chunks of memory at one time? here's my java version info.
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)
this is running on:
SunOS luna 5.8 Generic_117350-04 sun4u sparc SUNW,Sun-Fire-880
thank you very much.