Solved

Eclipse java.lang.OutOfMemoryError help

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now