How do I know which class calls OutOfMemory for the JVM?

An offline Weblogic server often crashes with an OutOfMemory error. Can I control the JVM in any way to find out which classes load memory and have the maximum number of objects?

+3
source share
5 answers

Yes. The way I did this was to configure jvm to create a dump heap in OOM, then I pulled out a bunch and ran it through jvisualvm. You can calculate the saved sizes (it takes a lot of time), but it will be very clear what the intruder is.

You can also connect jvisualvm to the running instance, but you need to configure jvm to accept the connection. Thus, you can observe how the heap grows in real time. To see it; its for jboss but it should be very similar: https://wiki.projectbamboo.org/display/BTECH/VisualVM+Profiler

I think it’s easier to get an answer after you have a bunch of heaps, although when you watch it in real time, everyone collects trash and something else.

EDIT - these are my configurations to run.

-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=<ip-address> -XX:+HeapDumpOnOutOfMemoryError   
-XX:HeapDumpPath=/path/to/heapdumps/ -XX:+CMSClassUnloadingEnabled   
-XX:+CMSPermGenSweepingEnabled -XX:+UseConcMarkSweepGC  

, , memlog.txt , , . jvm, , , , , , , , ...

+4

JConsole JDK 1.5 ( 5.0, ).

+2

, Eclipse Memory Analysis Toolkit. , JVM .

+2

JConsole, jRat - free-as-in-beer, YourKit - .

+2

From some other Questions, I learned about jhat and jmap. They are already available in JDK packages. Also the link below contains a good list on which tool to use in which scenarios: -

http://java.sun.com/developer/technicalArticles/J2SE/monitoring/

0
source

Source: https://habr.com/ru/post/1793127/


All Articles