gagaliya
asked on
Eclipse java.lang.OutOfMemoryError help
Hi, i am getting "Exception in thread "Thread-3" java.lang.OutOfMemoryError : Java heap space" while running my java program in eclipse.
1) I already increased the Xms=256m & Xmx=1024m in eclipse.ini & exe (c:\eclipse\eclipse.exe -vmargs -Xms512m -Xmx1024m)
2) In the java program itself, i added the print out per below at various points in the code, it clearly is showing the memory is not being allocated. Can someone help on how to increase the memory correctly? thanks
1) I already increased the Xms=256m & Xmx=1024m in eclipse.ini & exe (c:\eclipse\eclipse.exe -vmargs -Xms512m -Xmx1024m)
2) In the java program itself, i added the print out per below at various points in the code, it clearly is showing the memory is not being allocated. Can someone help on how to increase the memory correctly? thanks
AT START OF PROGRAM (in megabytes):
free memory: 8
allocated memory: 15
max memory: 247
total free memory: 240
RIGHT BEFORE IT THROWS THE OUTOFMEMORY EXCEPTION
free memory: 4
allocated memory: 247
max memory: 247
total free memory: 4
private void printMemory()
{
Runtime runtime = Runtime.getRuntime();
long maxMemory = runtime.maxMemory();
long allocatedMemory = runtime.totalMemory();
long freeMemory = runtime.freeMemory();
System.out.println("free memory: " + freeMemory / 1048576);
System.out.println("allocated memory: " + allocatedMemory / 1048576);
System.out.println("max memory: " + maxMemory /1048576);
System.out.println("total free memory: " +
(freeMemory + (maxMemory - allocatedMemory)) / 1048576);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.