查看 TiDB运行 内存快照分析

前置条件
[tidb@dev10 ~]$ yum install -y golang
TiDB 内存快照分析
[tidb@dev10 ~]$ go tool pprof 192.168.180.33:10080/debug/pprof/heap
或者

curl -G pd的IP:10080/debug/pprof/heap > heap.profile

[tidb@dev10 ~]$ curl -G 192.168.180.33:10080/debug/pprof/heap > heap.profile

[tidb@dev10 ~]$
[tidb@dev10 ~]$ go tool pprof heap.profile
File: tidb-server
Build ID: 40bee8740e5b8cb4930a3d0efa0fa7231d2e8116
Type: inuse_space
Time: Sep 18, 2019 at 3:55pm (CST)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof)
(pprof) top 10
Showing nodes accounting for 154.68MB, 79.82% of 193.79MB total
Dropped 77 nodes (cum <= 0.97MB)
Showing top 10 nodes out of 174
      flat  flat%   sum%        cum   cum%
      96MB 49.54% 49.54%       96MB 49.54%  github.com/pingcap/tidb/store/tikv/latch.NewLatches
   15.99MB  8.25% 57.79%    15.99MB  8.25%  github.com/pingcap/tidb/util/arena.NewAllocator
    9.66MB  4.98% 62.77%     9.66MB  4.98%  bufio.NewReaderSize
    8.06MB  4.16% 66.93%     8.06MB  4.16%  github.com/pingcap/tidb/statistics.NewCMSketch
    6.60MB  3.41% 70.34%     6.60MB  3.41%  github.com/pingcap/parser.New
    4.06MB  2.10% 72.43%     4.06MB  2.10%  bufio.NewWriterSize
    3.72MB  1.92% 74.36%     3.72MB  1.92%  google.golang.org/grpc/internal/transport.newBufWriter
    3.59MB  1.85% 76.21%     7.60MB  3.92%  github.com/pingcap/tidb/util/chunk.(*column).appendBytes
    3.50MB  1.81% 78.01%    14.55MB  7.51%  github.com/pingcap/tidb/statistics/handle.(*Handle).initStatsHistograms4Chunk
    3.50MB  1.81% 79.82%     3.50MB  1.81%  reflect.New
(pprof)

used - buff/cache = 实际使用内存
[root@dev11 ~]# free -h
              total        used        free      shared  buff/cache   available
Mem:            15G        6.3G        7.8G         81M        1.6G         13G
Swap:            0B          0B          0B
[root@dev11 ~]#
1赞