Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Profiling a C or C++ based application that never exits [closed]

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 ..

like image 460
codingfreak Avatar asked Dec 13 '22 23:12

codingfreak


2 Answers

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

like image 72
Didier Trosset Avatar answered Dec 15 '22 14:12

Didier Trosset


dtrosset's point is well put but apparently misunderstood. Add a means to terminate the program so you can perform a clean analysis. This can be something as simple as adding a signal handler for SIGUSR1, for example, that terminates the program at a point in time you decide. There are a variety of methods at your disposal depending on your OS.

There's a big difference between an application which never exits (embedded, daemons, etc) and one that cannot be exited. The prior is normal, the latter is bad design.

If anything, that application can be forcibly aborted (SIGKILL on *nix, terminate on win32) and you'd get your analysis. That method doesn't give your application the opportunity to clean up before it's destroyed so there will be very likely be retained memory reported.

like image 33
brlcad Avatar answered Dec 15 '22 13:12

brlcad