• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get rid of java.lang.outof memoryerror

 
jignesh soni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
jignesh soni
Ranch Hand
Posts: 150
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20610
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic