yerekla
yerekla

Reputation: 111

Java: Finding out what is using all the memory

I have a java application that runs out of memory, but I have no idea which code is allocating the memory. Is there an application with which I can check this? I use Eclipse.

Upvotes: 3

Views: 1679

Answers (10)

fglez
fglez

Reputation: 8552

I've spotted memory leaks using HP Diagnostics Profiler free evaluation (unlimited for 5 threads). It allows to trace memory allocation and do heap analysis in a visual, easy way.

Upvotes: 0

Ben Fitzgerald
Ben Fitzgerald

Reputation: 803

I had to find the source of a memory leak that produced a 2.6G heap dump the other day. Jhat required an unbelievable 20G heap size to crunch through it without crashing. Eclipse memory analyzer did it in under 10G. That said, I found both tools useful, but would recommend memory analyzer first for more efficient use of memory and being more easy to use.

I was pretty amazed by the amount of memory used but I can assure you if I used less I head OutOfMemory errors.

Upvotes: 0

LB40
LB40

Reputation: 12331

For fast profiling or if you don't use Eclipse or older versions of the jvm, hprof is a decent alternative. (I just add that as a reference.).

Upvotes: 1

broschb
broschb

Reputation: 5006

Since you use eclipse I would recommend the Eclipse Memory Analyzer plugin. This tool works great, and will even provide a report with some likely leak suspects. I have looked at over 1G heap dumps with this with no problems. I just use jconsole included with the JDK to get the dump.

Also here is a great blog on using the tool, by one of the authors of the tool.

This is also free.

Upvotes: 9

cetnar
cetnar

Reputation: 9415

VisualVM is a visual tool integrating several commandline JDK tools and lightweight profiling capabilities. Designed for both production and development time use, it further enhances the capability of monitoring and performance analysis for the Java SE platform.

And it is included in JDK.

Upvotes: 5

Seth
Seth

Reputation: 5738

I'm sure everyone has their favorite, but I recommend Netbeans.

Upvotes: 2

rob
rob

Reputation: 6247

You need to use a memory profiler. You can either use Sun's JVM Tool Interface or a third-party profiler like JProfiler. Eclipse also has profiling tools, called the Test & Performance Tools Platform (TPTP).

Upvotes: 2

Chris K
Chris K

Reputation: 12351

Yourkit is a great tool that I've used on MANY occasions to find and document performance issues. Eclipse with the TPTP framework can be used to do this as well. It also works well against remote application servers (you need to enable profiling agents and turn on remote debugging in the JVM), but it lets you run profiling against pretty much any J2EE environment.

Upvotes: 1

tinkertime
tinkertime

Reputation: 3042

I've had great success with JProfiler

http://www.ej-technologies.com/products/jprofiler/overview.html

Upvotes: 4

MarkPowell
MarkPowell

Reputation: 16540

You want a Profiler.

Here is a comprehensive list.

Upvotes: 3

Related Questions