• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Memory Leaks and OutOfMemory

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Folks,

My App server contains more than 50 web modules and 10 ejb modules,
I am getting java.lang.OutOfMemory error often.

Later i heard that it might be because of memory leaks (Example : an application running an infinite loop which eats up the memory).

But my idea is to identify where and why this is happening ?
It is very difficult for me to debug by looking to each and every module.

So is there any tool that resolves my problem, probably a monitoring tool that should tell how much memory each module is occupying at a given time.

JDK Version : 1.4
Max JVM Heap Size specified : 256

Correct me if my approach is wrong.

Thanks Ragav.
 
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use JProfiler for this. It's not free, though it's cheaper than some alternatives.

The JDK includes "hprof", and related tools, which can track objects on the heap and do some analysis. In fact, you can do with JDK tools quite a proportion of what something like JProfiler can - but a lot less easily. Search the JDK docs for more.
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are saying your app server has 50 wars, and 10 ejb's that seems like way too much for 256mb of memory.
 
Ranch Hand
Posts: 288
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Raghven k b:
Hello Folks,

My App server contains more than 50 web modules and 10 ejb modules,
I am getting java.lang.OutOfMemory error often.

Later i heard that it might be because of memory leaks (Example : an application running an infinite loop which eats up the memory).

But my idea is to identify where and why this is happening ?
It is very difficult for me to debug by looking to each and every module.

So is there any tool that resolves my problem, probably a monitoring tool that should tell how much memory each module is occupying at a given time.

JDK Version : 1.4
Max JVM Heap Size specified : 256

Correct me if my approach is wrong.

Thanks Ragav.



More than likely it is the memory setting that are incorrect rather than a memory leak. 256 does sound much too low indeed. What Application server are you using? It would be worth changing the max size of the heap when starting the application to 512 or 1024 if the memory on the box allows.
 
Baskaran Ragav
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks folks for your suggestions.
Will try increasing the size of the heap and see what is happening.
I am using WAS 4.0.

Meanwhile few more questions arises in the same context,

what is the default value of the heap size if nothing is specified ?

and

What is the criteria to specify the heap size just specifying at random like(256, 512 or 1024) won't work for all the cases. Any guidelines to choose this heap size ?

Will the JVM be capable enough to increase/decrease the heap size automatically . Is there any settings that i can make at JVM level or at App Server level to do this ?

Thanks Ragav.
Prevention is better than cure.
 
Peter Chase
Ranch Hand
Posts: 1970
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Raghven k b:

Will the JVM be capable enough to increase/decrease the heap size automatically . Is there any settings that i can make at JVM level or at App Server level to do this ?



Yes, at least if you're using Sun JVM. If the max and min heap size settings are not the same, the JVM will adjust the heap size up and down between those limits, according to demand.

However, to avoid thrashing the memory allocator/deallocator, the JVM is by default not very keen to change heap size, particularly downward. This is configurable, though, using the -XX:MinHeapFreeRatio and -XX:MaxHeapFreeRatio JVM options.
 
If somebody says you look familiar, tell them you are in porn. Or in these tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic