How to find which Class is causing OutOfMemory for the JVM?

Yes. The way I did it was to configure the jvm to create a heap dump on OOM, then I pulled the heap down and ran it thru jvisualvm. You can compute the retained sizes (took a long time) but it will be very clear what the offender is.

Yes. The way I did it was to configure the jvm to create a heap dump on OOM, then I pulled the heap down and ran it thru jvisualvm. You can compute the retained sizes (took a long time) but it will be very clear what the offender is.

You can also attach jvisualvm to a running instance, but you need to configure the jvm to accept the connection. That way you can watch the heap grow in real time. See this; its for jboss but should be very similar: https://wiki.projectbamboo.Org/display/BTECH/VisualVM+Profiler I think it is easier to get to the answer after you have a heap dump though, as when you watch it in real time things get garbage collected and whatnot.

EDIT -- here are my startup configs. -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -Xloggc:/path/to/memlogs/memlog. Txt -XX:+PrintTenuringDistribution -Xms1024m -Xmx2048m -XX:MaxPermSize=128m -server -Dcom.sun.management.

Jmxremote -Dcom.sun.management.jmxremote. Port=xxxx -Dcom.sun.management.jmxremote. Ssl=false -Dcom.sun.management.jmxremote.

Authenticate=false -Djava.rmi.server. Hostname= -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heapdumps/ -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+UseConcMarkSweepGC because I configured it to drop memory logs, I can tail the memlog. Txt file in real time to see what happened.

I can connect to the jvm if I want, but like I said I will just analyze the heap after a crash to see what the issue is, because after the fact its really clear....

– AppleGrew Feb 20 at 4:45 I guess I need use -XX:+HeapDumpOnOutOfMemoryError flag. – AppleGrew Feb 20 at 4:47 @applegrew correct – hvgotcodes Feb 20 at 15:29.

There's JConsole as of JDK 1.5 (or 5.0, if you're into that).

Unfortunately with JConsole, it doesn't let me see the Classes that are loaded and hogging the most resource. I need that to guess the source of the OOM. – AppleGrew Feb 20 at 4:41.

There are a number of tools out there but I use Eclipse's Memory Analysis Toolkit. You can download it as a standalone tool and it will let you do heap analysis and even connect to a JVM and analyze there.

Beyond JConsole, jRat is one good free-as-in-beer profiler, YourKit is another great commercial product.

From some other Questions I came to know about jhat and jmap. These are already available in JDK packages. Also the below link provides a good list on which tool to use in which scenarios:- java.sun.com/developer/technicalArticles....

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions