Git Product home page Git Product logo

Comments (1)

oldratlee avatar oldratlee commented on September 12, 2024 1

Java内存问题,可以的检查操作有:
# 下面的这些都不方便做成脚本直接得出jvm中最大对象。谁有方法脚本化 欢迎提供或是实现。 👍

查看不同类型占用的内存

$ jmap -histo <进程号> | head -n 20 
 num     #instances         #bytes  class name  
----------------------------------------------  
   1:         13352       60321384  [B  
   2:        108823       13516768  <constMethodKlass>  
   3:         89912        9476704  [C  
   4:        108823        8710200  <methodKlass>  
   5:        152780        6715552  <symbolKlass>  
   6:          8796        5325984  <constantPoolKlass>  
   7:          8796        4219536  <instanceKlassKlass>  
   8:         16753        3896104  [I  
   9:          7026        2782816  <constantPoolCacheKlass>  
  10:        109717        2633208  java.lang.String  
  11:         40391         969384  java.util.HashMap$Entry  
  12:         13806         932104  [Ljava.lang.Object;  
  13:          9400         902400  java.lang.Class  
  14:          8076         854312  [Ljava.util.HashMap$Entry;  
  15:         11426         794936  [S  
  16:         13935         685408  [[I  

查看JVM内存消耗和GC情况

$ jstat -gcutil 17708 1000
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
 35.93   0.00  22.05   2.01  38.92      4    0.156     0    0.000    0.156
 35.93   0.00  22.05   2.01  38.92      4    0.156     0    0.000    0.156
 35.93   0.00  22.05   2.01  38.92      4    0.156     0    0.000    0.156
 35.93   0.00  22.05   2.01  38.92      4    0.156     0    0.000    0.156
 35.93   0.00  22.05   2.01  38.92      4    0.156     0    0.000    0.156

Dump内存,查看对象消耗

这个是 最直接准确的,当然操作也繁琐些。

$ jmap -dump:file=heap.bin <进程号> 
Dumping heap to /path/to/heap.bin ...  
Heap dump file created  

然后用工具分析Dump文件,可以用工具MAT。一般很容易就看到内存泄漏对象。

通过查看对象引用关系,可以分析出内存泄漏的原因。

from useful-scripts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.