Solved

Eclipse java.lang.OutOfMemoryError help

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

Independent Software Vendors: 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
swing controls 2 35
collection output issue 9 89
java mysql insert application 14 65
DTD and JAVA versions 1 53
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

739 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