Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Memory Leakage

  Asked By: Richard    Date: May 23    Category: Java    Views: 652

I get this OutOfMemory exception now and then in my application. I guess there would be a memory leakage somewhere in it, but I couldn't find where it might be.
is there any specific tool or sth to find memory leakage in java?
Send instant messages to your online friends http://uk.messenger.yahoo.com



4 Answers Found

Answer #1    Answered By: Willard Washington     Answered On: May 23


Or google java+profile+tool

Answer #2    Answered By: Emily Brown     Answered On: May 23

An OutOfMemoryException is not necessarily a result of memory  leakage. You may also need to allow JVM to allocate more memory while gc is finding the best time to release dangling objects. However, the barmak's JProfiler solution is a determind way to find  memory consumption points.

Answer #3    Answered By: Jarrod Williams     Answered On: May 23

this is a very general question. i do not know any specific  tool to find  mem leak but u can use any mem profiler. they can show memory  usage in ur application. then u can find the place where extra mem is being wasted...
if u are using a server take a look at its mem parameters and tools. all servers have some mem allocation parameters.
if u are not using a server change ur jvm heap size etc.

Answer #4    Answered By: Evelyn Hughes     Answered On: May 23

OutOfMemory can happen in two scenarios:
1. You have leakage in your code
2. The JVM garbage collector paused

To solve the problem, do a stress testing on your application  to find  out how long it will take for the JVM to capture the OutOfMemory excpetion. Then change the JVM generational collector(for garbage collection) to the other three models provided by your Sun JVM. Tune some of the parameters, see if you can still get this exception. If you still get it, then you need to do some memory  profiling. The commercial tools are all too generic, it is not easy to find out the leakage. A simple method is instantiate a WeakHashmap object, and add all you application related java collection objects to this weak hashmap, add a timer task to print out memory footprint(the objects and each object size in the hashmap), analyze the result, you should be able to find the leakage. If there is no leakage in the collection objects, add other application initiated objects to the hashmap for analysis.

If you have less than 50 aggressive threads in your application, chances are you have leakage in your code.

Didn't find what you were looking for? Find more on Memory Leakage Or get search suggestion and latest updates.