LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-03-2008, 05:45 AM   #1
manolakis
Member
 
Registered: Nov 2006
Distribution: xubuntu
Posts: 464

Rep: Reputation: 37
Java Heap Space


Hi there

Does anybody know how to overcome the following exception?

Quote:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at sun.misc.FloatingDecimal.dtoa(FloatingDecimal.java:661)
at sun.misc.FloatingDecimal.<init>(FloatingDecimal.java:442)
Thanks
 
Old 02-03-2008, 07:38 AM   #2
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
Most likely, your application has a memory leak. Try to increase the heap space like this:

java -Xms128m -Xmx512m

That will reserve a minimum of 128Mb for the heap, with a max of 512Mb. I am not sure what the default values are though... but I'd still check for memory leak first.
 
Old 02-03-2008, 12:29 PM   #3
Alien_Hominid
Senior Member
 
Registered: Oct 2005
Location: Lithuania
Distribution: Hybrid
Posts: 2,247

Rep: Reputation: 53
If I remember correctly, default is 64Mb.
 
Old 02-04-2008, 11:15 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,636
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
If you are experiencing heap-overflow problems in a language like Java, it's important to understand key principles of how such languages are designed to work: most importantly, garbage collection.

Unlike languages such as "C," you don't have to explicitly free anything. You can acquire a new object, use it, and forget about it. The garbage-collection routines will clean up after you, reclaiming the space you're no longer using.

The Java specification does not stipulate how the garbage collector will work, only that there must be one. The most common implementation for a garbage-collector uses reference counting. An object continues to exist until its reference-count becomes zero. Counter-based garbage collectors are favored because they are both reliable and efficient.

Heap-overflow problems often occur because of self-references. In other words, a chain of objects exists such that all of them refer to each other, so the reference-count for any of them never drops to zero.

The classical solution to this problem is to use one or more of what are called "weak references" when building the structure. These are references which do not prevent the referent from being garbage-collected. Instead, whenever the referent is reaped, the weak-references to it are "cleared."

Languages such as Java also highly-favor the notion that you should never have to build what you can simply get "off the shelf." Therefore, when you design things be sure that you're not being too clever; you're not being too manual. If there's an off-the-shelf package or class that does what you need to do, by all means use it. If you find yourself hand-building, say, "linked list" code in a system like Java, "friend, you are doing something very wrong."

Last edited by sundialsvcs; 02-04-2008 at 11:19 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Find Java Heap Leaks with HeapAnalyzer LXer Syndicated Linux News 0 10-20-2007 07:41 AM
Heap in nasm des_a Programming 2 06-24-2007 11:17 PM
Java process memory space 32/64 Woody Benot Red Hat 0 06-06-2007 04:07 AM
heap or stack yashwantpinge Programming 1 03-17-2006 07:25 AM
How big can Java-heap be on a 64-bit Linux betbrain Linux - Enterprise 0 08-29-2005 04:58 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:37 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration