【问题标题】:Measuring dynamic memory usage using C++ sanitizers [closed]使用 C++ 消毒剂测量动态内存使用情况 [关闭]
【发布时间】:2018-06-06 06:56:45
【问题描述】:

我正在寻找一种简单的方法来测量 C++ 应用程序使用的总内存。我知道 valgrind,但最近我遇到了 C++ 的内存清理器。是否可以使用任何消毒剂测量 C++ 可执行二进制文件使用的最大堆/堆栈内存?

【问题讨论】:

  • 这不是消毒剂的用途,所以我认为你不能,但你可以通过其他方式做到这一点
  • 除了 Valgrind 还有什么其他方法?
  • 这些不是 C++ 消毒剂,而是 GCC 或 Clang 消毒剂。而且“使用的总内存”没有多大意义(给定进程可以在Linux上使用mmap获取内存并使用munmap释放内存,因此使用的内存随时间变化)

标签: c++ gcc memory clang


【解决方案1】:

使用time -v 可以为您提供有关应用程序的大量有用信息:

    System time (seconds): 0.00
    Percent of CPU this job got: 0%
    Elapsed (wall clock) time (h:mm:ss or m:ss): 0:05.00
    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): 2144
    Average resident set size (kbytes): 0
    Major (requiring I/O) page faults: 0
    Minor (reclaiming a frame) page faults: 179
    Voluntary context switches: 2
    Involuntary context switches: 1
    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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-02
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-31
    相关资源
    最近更新 更多