zl程序教程

您现在的位置是:首页 >  后端

当前栏目

c/c++中类似于java jprofiler/eclispe memoryanalysis的性能瓶颈以及内存泄露分析工具

JAVAC++内存性能工具 分析 以及 泄露
2023-09-27 14:28:34 时间

visual studio有自带的,可以看MSDN,不过一般来说,我们比较关注linux下的,搜了下,比较好用的应该有gprof和valgrind(可以分析内存潜在的泄露,如针对json-c/log4c进行分析),先记录。可参考如下:

http://blog.csdn.net/clarstyle/article/details/41747817?utm_source=itdadao&utm_medium=referral

http://gernotklingler.com/blog/gprof-valgrind-gperftools-evaluation-tools-application-level-cpu-profiling-linux/

对于性能分析,推荐gcc perf命令行工具(https://zhuanlan.zhihu.com/p/186208907,使用上这个更合适),没有之一。

perf record -a --call-graph dwarf -p PID

perf report

上述命令生成的就是调用链。

# To display the perf.data header info, please use --header/--header-only options.
#
#
# Total Lost Samples: 0
#
# Samples: 411K of event 'cycles:uppp'
# Event count (approx.): 415626554486
#
# Children      Self  Command  Shared Object       Symbol                                 
# ........  ........  .......  ..................  .......................................
#
    86.20%     7.98%  lightdb  lightdb             [.] ReadBuffer_common
            |          
            |--80.75%--ReadBuffer_common
            |          |          
            |           --80.75%--BufferAlloc (inlined)
            |                     |          
            |                     |--38.27%--StrategyGetBuffer
            |                     |          |          
            |                     |           --37.50%--GetBufferFromRing (inlined)
            |                     |                     |          
            |                     |                     |--14.59%--GetCurrCandidateNums
            |                     |                     |          |          
            |                     |                     |           --11.59%--GetPgwrCandidateNums (inlined)
            |                     |                     |                     |          
            |                     |                     |                      --0.89%--pg_atomic_read_u64 (inlined)
            |                     |                     |                                pg_atomic_read_u64_impl (inlined)
            |                     |                     |          
            |                     |                     |--9.72%--LockBufHdr
            |                     |                     |          |          
            |                     |                     |          |--8.18%--pg_atomic_fetch_or_u32 (inlined)
            |                     |                     |          |          pg_atomic_fetch_or_u32_impl (inlined)
            |                     |                     |          |          
            |                     |                     |           --0.54%--init_spin_delay (inlined)
            |                     |                     |          
            |                     |                      --3.85%--pg_atomic_read_u32 (inlined)
            |                     |                                pg_atomic_read_u32_impl (inlined)

 

perf使用可参见:https://blog.csdn.net/jasonactions/article/details/109332167https://perf.wiki.kernel.org/index.php/Main_Page

后面再专门针对性的研究。