简体   繁体   English

如何获得进程的内存和时间使用情况?

[英]How to get a process' memory and time usage?

I'm trying to get a process's memory and time usage,and here is [my code] but the memory reported is so much for such a simple app consuming almost 8500Kb. 我正在尝试获取进程的内存和时间使用情况,这是[我的代码],但是对于这样一个消耗近8500Kb的简单应用程序,报告的内存是如此之大。 Has something I've done reported the wrong memory usage or are there other reasons? 我有做过的事情报告了错误的内存使用情况,还是还有其他原因?

#include "trace.h"
#include "include.h"
#include "trace.cpp"
using namespace std;
int main(int argc, const char * argv[])
{
    trace t;
    t.SetLimitInfo();
    t.CreateProcess();
    t.waitForChild();


    cout<<"time usage: "<<t.getTime()<<"ms memory usage: "<<t.GetMemory()<<"kb"<<endl;
    // insert code here...
//    std::cout << "Hello, World!\n";
    return 0;
}

I would use valgrind --tool=massif to check memory usage. 我将使用valgrind --tool=massif检查内存使用情况。

Check the doc 检查文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何获得由gcc-mingw编译的进程的最大内存使用率 - how to get maximum memory usage of a process compiled by gcc-mingw 如何在没有root权限的情况下获取linux中进程的内存使用情况 - How to get the memory usage of a process in linux without root permission 从C ++获取进程的内存使用情况 - Get memory usage of a process from C++ 如何从32位进程中获取64位进程的可靠内存使用信息? - How to get a reliable memory usage information for a 64-bit process from a 32-bit process? 增加进程的内存使用量 - Increased memory usage for a process How to get execution time and memory usage of a program (c,c++,java,python,php) in php script on ubuntu? - How to get execution time and memory usage of a program (c,c++,java,python,php) in php script on ubuntu? 如何获取线程状态(例如暂停),内存+ CPU使用率,启动时间,优先级等 - How to get thread state (e.g. suspended), memory + CPU usage, start time, priority, etc Linux进程分配的内存使用情况 - Linux process allocated memory usage Linux:如何衡量进程内线程的内存使用情况? - Linux: How to measure memory usage for a thread within process? 如何以编程方式获取当前程序的 memory 使用情况? - How to programatically get the memory usage of the current program?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM