23 Eylül 2022 Cuma

Heap Dump Alma Yöntemleri

Heap Dump Nedir
Açıklaması şöyle
A heap dump is a snapshot of JVM memory. Typically it would be a large binary file with .hprof extension that is roughly the same size as the heap of the application at the moment it is taken.
Heap Dump Oluşturmak
Uygulama çökmese bile heap dump oluşturmak mümkün. Bazı çözümler anlatan bir yazı burada.

Hata Oluşmadan Elle Çalıştırılan Komutlar
1. jmap komutu kullanılabilir.
2. jcmd komutu kullanılabilir.
3. JVisualVM kullanılabilir
4. JMX kullanılabilir. Açıklaması şöyle. Bu JMX bean'i aynı zamanda kod içinde çağırmak ta mümkün.
There is a com.sun.management:type=HotSpotDiagnostic MBean. This MBean has ‘dumpHeap’ operation. Invoking this operation will capture the heap dump. ‘dumpHeap’ operation takes two input parameters:

outputFile: File path where heap dump should be written
live: When ‘true’ is passed only live objects in heap are captured
Hata Olunca Heapdump Almak
1. java komutu OutOfMemoryError seçenekleri kullanılabilir

Heap dump analyzer
Bu dosyayı bir heap dump analyzer ile incelemek gerekir. Heap dump alırken sadece  live nesneleri görmek işi kolaylaştırabilir. Açıklaması şöyle
Note: It’s quite important to pass “live” option. If this option is passed, then only live objects in the memory are written into the heap dump file. If this option is not passed, all the objects, even the ones which are ready to be garbage collected are printed in the heap dump file. It will increase the heap dump file size significantly. It will also make the analysis tedious. To troubleshoot memory problems or optimize memory, just the “live” option should suffice the need.

Hiç yorum yok:

Yorum Gönder