944,144 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 1948
  • Java RSS
Sep 14th, 2005
0

OutOfMemory Error

Expand Post »
Hi

I got runtime error as "Exception in thread "main" java.lang.OutOfMemoryError: Java heap space ". How can I solve this problem? Can anyone explain me why this problem occurs? Thanks in advance.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
perlsu is offline Offline
17 posts
since Sep 2005
Sep 14th, 2005
0

Re: OutOfMemory Error

I would guess you're using recursion...maybe?
Recursion can cause this, and so can many other things. Explain what your program is doing, please.
Reputation Points: 113
Solved Threads: 19
Postaholic
server_crash is offline Offline
2,108 posts
since Jun 2004
Sep 14th, 2005
0

Re: OutOfMemory Error

Recursion causes StackOverflow, not often OutOfMemory

You're probably trying to read in some very large file or otherwise reserving a lot of memory.
Figure out where you are doing that and try to find a way around it.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Sep 14th, 2005
0

Re: OutOfMemory Error

Just adding to what the two above stated...

Look to see if you're creating lots of new objects. Memory Exceptions ocure when your java application uses all of its allowed memory. I believe the default setting is 64megs. My guess is that inside a loop (if, while, or a recursive loop) there are new objects being created. While this isn't bad, it could be the source of the problem.

Regards,

Nate
Reputation Points: 11
Solved Threads: 8
Posting Whiz in Training
hooknc is offline Offline
216 posts
since Aug 2005
Sep 20th, 2005
0

Re: OutOfMemory Error

Hi everyone,

I thnk you will have to use -Xms and -Xmx as such

Java Syntax (Toggle Plain Text)
  1. java -Xms<initial heap size> -Xmx<maximum heap size>

You best bet is make your own mini application launcher to get around this problem.

Richard West
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004
Sep 20th, 2005
0

Re: OutOfMemory Error

Unless there's a definite limit to the amount of memory the application will claim (so no errors or unforeseen conditions causing infinite loops for example) that will only delay the inevitable
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: JVM reaction to multiple programs?
Next Thread in Java Forum Timeline: Quicktime and MPEG4





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC