English 中文(简体)
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.

最佳回答

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.

问题回答

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.

You want a Profiler.

Here is a comprehensive list.

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).

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

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.

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.).

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.

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.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签