zoukankan      html  css  js  c++  java
  • 对于linux 程序内存的使用量

    简介

    如何查看一个linux程序是否产生内存泄露了呢??
    可以使用valgrind

    一般的命令是 valgrind --leak-check=full --show-reachable=yes --trace-children= yes ./a

    执行结果

    ==771938== Memcheck, a memory error detector
    ==771938== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==771938== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
    ==771938== Command: ./a
    ==771938== 
    0 : 496
    [DEBUG] read finish ; ) 
    [DEBUG] write finish ; ) 
    ==771938== 
    ==771938== HEAP SUMMARY:
    ==771938==     in use at exit: 0 bytes in 0 blocks
    ==771938==   total heap usage: 102,200 allocs, 102,200 frees, 5,431,706 bytes allocated
    ==771938== 
    ==771938== All heap blocks were freed -- no leaks are possible // 没有泄露
    ==771938== 
    ==771938== For lists of detected and suppressed errors, rerun with: -s
    ==771938== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
    

    参考链接

    https://blog.csdn.net/andylauren/article/details/93189740

    /usr/bin/time -v ./a

    /usr/bin/time -v ./a
    0 : 496
    [DEBUG] read finish ; ) 
    [DEBUG] write finish ; ) 
            Command being timed: "./a"
            User time (seconds): 0.06
            System time (seconds): 0.01
            Percent of CPU this job got: 77%
            Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.10
            Average shared text size (kbytes): 0
            Average unshared data size (kbytes): 0
            Average stack size (kbytes): 0
            Average total size (kbytes): 0
            Maximum resident set size (kbytes): 6636
            Average resident set size (kbytes): 0
            Major (requiring I/O) page faults: 0
            Minor (reclaiming a frame) page faults: 872
            Voluntary context switches: 3731
            Involuntary context switches: 0
            Swaps: 0
            File system inputs: 0
            File system outputs: 0
            Socket messages sent: 0
            Socket messages received: 0
            Signals delivered: 0
            Page size (bytes): 4096
            Exit status: 0
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    linux 查看磁盘空间
    nginx面试中最常见的18道题
    spring -mvc service层调用工具类配置
    IntelliJ IDEA tomcat 远程Ddbug调试
    IntelliJ IDEA tomcat 热部署
    Java HttpClient PostMethod
    Java Base64 加密/解密
    启动tomcat时cmd窗口一闪而过
    remote staging type or host is not specified
    Maven更新后本地仓库jar后缀带有 lastUpdated
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/14900961.html
Copyright © 2011-2022 走看看