aspose file tools*
The moose likes Beginning Java and the fly likes how to get rid of java.lang.outof memoryerror Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to get rid of java.lang.outof memoryerror" Watch "how to get rid of java.lang.outof memoryerror" New topic
Author

how to get rid of java.lang.outof memoryerror

jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
I am getting "java.lang.outofmemoryerror" , when I am trying to access an application. Whats the reason that I am getting this error and how to get rid of this error ?

Thanks
Harvinder Thakur
Ranch Hand

Joined: Jun 10, 2008
Posts: 231
That is a very generalized question. Actually you get outofmemory error when jvm does not have enough memory on the heap for creating new objects.
Generally the default heapsize can be altered by two VM arguments
-Xms256m (for initial heap size) and -Xmx512m (for max. heap size) to allocate the heap size to be allocated to your java application. The arguments to the VM above depend upon the actual memory you have.
The above optimization works assuming that you don't have any memory leaks in your application code. If you still find such problems i suggest that you use an appropriate java memory profiler to identify any memory leaks.
I suggest that you have a look at the java performance forum also.


thanks
Harvinder
jignesh soni
Ranch Hand

Joined: Dec 10, 2007
Posts: 150
Actually I am trying to understand basics of this problem. When the user is getting "java.lang.outofmemoryerror" , does it mean there is not enough space on the server to create thread ?

How can I check, what existing heapsize is ?

Wheer do I execute -Xmx512m command ? On the command prompt on server ?

thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Yes, you execute -Xmx as a command line option. This is the java tool webpage.

If a beginner gets OutOfMemoryErrors, it is likely there is a code error causing infinite recursion or filling of memory.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19784
    
  20

Originally posted by jignesh soni:
Actually I am trying to understand basics of this problem. When the user is getting "java.lang.outofmemoryerror" , does it mean there is not enough space on the server to create thread ?

The JVM only has a limited amount of memory it can access; I believe it is 64MB by default. Once it reaches this limit it there is no more memory available for the JVM (even though the operating system does) and the error is thrown. The mentioned flags can change that limit for you.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

Originally posted by jignesh soni:
does it mean there is not enough space on the server to create thread?
What "server" is that? And why do you think that threads are involved?

It might help if you posted the stack trace as well. Copy and paste it, don't try to retype the whole thing.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get rid of java.lang.outof memoryerror