DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   OutOfMemory Error (http://www.daniweb.com/forums/thread32286.html)

perlsu Sep 14th, 2005 6:22 am
OutOfMemory Error
 
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.

server_crash Sep 14th, 2005 7:11 am
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.

jwenting Sep 14th, 2005 8:06 am
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.

hooknc Sep 14th, 2005 11:27 am
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

freesoft_2000 Sep 20th, 2005 1:03 pm
Re: OutOfMemory Error
 
Hi everyone,

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

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

jwenting Sep 20th, 2005 4:05 pm
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 :)


All times are GMT -4. The time now is 11:37 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC