Profiling a C or C++ based application that never

2019-05-06 22:16发布

I have a small doubt regarding profiling applications which never exit until we manually reboot the machine.

I used tools like valgrind which talks about memory leaks or bloating of any application which exits after sometime.

But is there any tool which can be used to tell about memory consumption, bloating, overhead created by the application at various stages if possible?

NOTE: I am more intrested to know about apps which dont exit ... If an app exits I can use tools like valgrind ..

13条回答
ら.Afraid
2楼-- · 2019-05-06 22:31

Have you tried GNU Gprof?

Note that in this document, "cc" and "gcc" are interchangeable. ("cc" is assumed as an alias for "gcc.") http://www.cs.utah.edu/dept/old/texinfo/as/gprof_toc.html

查看更多
老娘就宠你
3楼-- · 2019-05-06 22:34

Profiling is intrusive, so you don't want to deploy the app with the profiler attached, anyway. Therefore, include some #ifdef PROFILE_MODE-code that exits the app after an appropriate amount of time. Compile with -DPROFLILE_MODE, profile. Deploy without PROFILE_MODE.

查看更多
Juvenile、少年°
4楼-- · 2019-05-06 22:35

I have used rational purify API's to check incremental leaks. Haven't used the API's in linux. I found the VALGRIND_DO_LEAK_CHECK option in Valgrind User Manual, I think this would suffice your requirement.

查看更多
劳资没心,怎么记你
5楼-- · 2019-05-06 22:36

Rational Purify can do that, at least on windows. There seem to be a linux version but I don't know if it can do the same.

查看更多
再贱就再见
6楼-- · 2019-05-06 22:39

I'd consider adding a graceful exit from the program.

查看更多
Deceive 欺骗
7楼-- · 2019-05-06 22:41

Modify your program slightly so that you can request a Valgrind leak check at any point - when the command to do that is recieved, your program should use VALGRIND_DO_LEAK_CHECK from memcheck.h (this will have no effect if the program isn't running under Valgrind).

查看更多
登录 后发表回答