?
Solved

Eclipse java.lang.OutOfMemoryError help

Posted on 2012-04-03
1
Medium Priority
?
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 36

Accepted Solution

by:
mccarl earned 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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.
In this post we will learn different types of Android Layout and some basics of an Android App.
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…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

762 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