• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to get rid of java.lang.outof memoryerror

 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22781
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic