通过比对不同时间的pmap输出结果,发现000000000078f000起始地址的内存地址内存持续增长
pmap -x 26351 26351: ruby test.rb Address Kbytes RSS Dirty Mode Mapping 0000000000400000 4 4 0 r-x-- ruby 0000000000600000 4 4 4 rw--- ruby 000000000078f000 8308 8200 8200 rw--- [ anon ] 0000003434800000 128 116 0 r-x-- ld-2.12.so ---------------- ------ ------ ------ total kB 168724 12456 86202:获取结束地址
根据持续增长的内存地址起始地址,得到其内存地址的结束地址0078f000-00f28000
cat /proc/26351/maps 00400000-00401000 r-xp 00000000 08:03 832052 /usr/local/bin/ruby 00600000-00601000 rw-p 00000000 08:03 832052 /usr/local/bin/ruby 0078f000-00f28000 rw-p 00000000 00:00 0 [heap]3:gdb dump内存
起始地址,结束地址前需要加上0x
gdb --batch-silent --eval-command 'dump memory /tmp/test 0x7fe3fc000000 0x7fe4036a0000' -p 9395 gdb --batch-silent --eval-command 'dump memory /tmp/test 0x7f18e4000000 0x7f18e8000000' -p 7f18e4000000-7f18e80000004:格式化dump内存文件,分析结果
strings /tmp/test | more
r = {}; `strings /tmp/test`.split("n").each{|x| r.has_key?(x) ? r[x] +=1 : r[x] = 1}; ''
r.sort_by{|k,v| v}.reverse[0..50]
参考文件:
ruby内存分配: https://www.jianshu.com/p/e4f184e92375



