File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Memory Leaks and OutOfMemory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Memory Leaks and OutOfMemory" Watch "Memory Leaks and OutOfMemory" New topic
Author

Memory Leaks and OutOfMemory

Baskaran Ragav
Greenhorn

Joined: Apr 13, 2007
Posts: 14
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.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
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.


Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 852
If you are saying your app server has 50 wars, and 10 ejb's that seems like way too much for 256mb of memory.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
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.


SCJP<br />SCJD
Baskaran Ragav
Greenhorn

Joined: Apr 13, 2007
Posts: 14
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

Joined: Oct 30, 2001
Posts: 1970
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Memory Leaks and OutOfMemory
 
Similar Threads
Which profilers are available to use?
Query regarding to know the memory leaks in Application
Search for Memmory testing tool
am stuck in Creating a Simple Program Using Jcreator
Eclipse very slow, any way to speed things up ?