Solved

Eclipse java.lang.OutOfMemoryError help

Posted on 2012-04-03
1
319 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JavaScript/Java - Changing an image background color 4 66
rhino JavaScript import, load 25 82
SHA2 certs for IIS AND Java? 2 81
tomcat startup error 5 59
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
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.

785 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