Question:
Java memory leak disapears while using a profiler.?
James D
2008-05-25 21:54:36 UTC
I have a Java web application running on Tomcat that's leaking memory.

When I run the application normally and hammer it with requests, it quickly baloons to fill 600mb of RAM, at which point the JVM seems to hang.

However when I run a profiler (Yourkit Java Profiler) against it, the memory usage sits at a constant 81mb RAM and doesn't go any higher no matter how many requests it processes.

It appears that running a memory profiler against my application fixes the memory leak, making it rather difficult to pinpoint.

There doesn't appear to be any differences in command line arguments between running tomcat normally and with the profiler, and in both cases I'm running the same JDK (1.6.0_03)

Anyone have any ideas?
Three answers:
Irony Man
2008-05-25 22:00:55 UTC
You must change your setting for Tomcat



Goto configure Tomcat



At the Apache Tomcat properties



Tab [Java]



Set initial memory to 64 MB

and maximum memory to 192 MB



The garbage collection will be trigger to reclaim memory when it hit 192 MB.



Update:

SUN JVM are not optimise.

You need to optimise it yourself, see website.



http://www.folgmann.com/en/j2ee/gc.html
leiter
2016-10-13 09:10:31 UTC
the only actual thank you to respond to it rather is to fully look on the code for capacity memory leaks. some basic reasons are themes like leaving archives in Arrays, Lists, ArrayLists or distinctive collections, and not explicitly putting off them, or dereferencing them. Instantiating contraptions with an exceedingly great quantity of social gathering variables that are actually not to any extent further eligible for rubbish sequence. distinctive threat is that your app is in ordinary terms overly great. memory leaks are obtainable, even at the same time as disposing each and every ingredient that the handbook e book says you're meant to, on account which you will desire to be utilising some subject that the handbook e book does not conceal (This 'rule e book' is hypothetical, by utilising utilising the way). All i'm in a position to declare is carefully look in any respect your code, and in all probability even grant it on your chum to look over.
rohit yadav
2008-05-25 22:06:22 UTC
tomcat doesnot handles memory leaks and dangling objects however Yourkit Java Profiler has built in features that optimize memory usage and prevent memory leaks by freeing up unused memory....

your program must be having terrible memeory leaks if CPU usage varies in range of 600 to 81 MB

try to free up memory by using System.gc() and closing DB connections and making sure that no objects are used unnecessarly


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...