Solved

Eclipse java.lang.OutOfMemoryError help

Posted on 2012-04-03
1
322 Views
Last Modified: 2012-04-25
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

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

Open in new window


    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);   
    }

Open in new window

0
Comment
Question by:gagaliya
1 Comment
 
LVL 35

Accepted Solution

by:
mccarl earned 500 total points
ID: 37804042
The eclipse.ini settings only apply to the JVM that is running Eclipse itself. When Eclipse runs your program, it starts a new JVM. So what you need to do is to go to your "Run Configurations" for your program and there should be a tab called 'Arguments' where you can enter "VM arguments" which will apply to the JVM that will run your program. Set your memory settings in there and you should be right to go!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate example using maven 12 77
Detect Closed Loops (circles, figure-8s, etc) in PNG Images 6 74
mysql jsp example issue 32 69
add projects t working set in maven 2 37
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question