Memory Leak Detection & Execution Times

Added by John Doe over 3 years ago

It would be nice to have some sort of memory leak detection as e.g. CppUTest provides.
The 'easy' way:
- e.g. check how much ressources are being consumed before a single test and re-check, after a single test has been executed
- check the heap

Additional features:
- I could not find anything about execution times of tests, functions and stuff like that. It would be nice to know, if changes on your code have an effect on the mentioned execution times...for example

The resulting additional information, as e.g. memory usage/execution times, could be written to the already existing *.xml-output-file....but I guess, you guys already had stuff like this in mind, when you were creating that output file.


Replies (2)

RE: Memory Leak Detection & Execution Times - Added by Peter Sommerlad about 3 years ago

As a C++ programmer using RAII it never occurred to me that a test might produce a memory leak. Even before C++11, one could use boost's smart pointers, if stuff must be on the heap.

A portable means would be to overload global operator new and delete to track heap memory usage, but one would also need to replace malloc/calloc/realloc/free substitutes, in case the code is using C libraries. Doing that for every test would incur too much overhead and it would be hard to test such replacement code with CUTE.

I suggest that one uses a separate memory profiling tool, such as valgrind and run the tests with it.

With respect to timing tests, one needs to use a dedicated listener that involves timing that you could also DIY. See the counting_listener as an example on how to do that.
However, that is something we could provide, esp. with C++11 where timers are standardized, but haven't done so yet, may be I can easily include it into the XML listener in a future version.

RE: Memory Leak Detection & Execution Times - Added by John Doe about 3 years ago

I'm in c++-programming since a while now, but not so deeply involved that I could have seen this kind of I do. :-D
Thanks for your advice Peter regarding the memory leak detection AND the execution time profiler!

No haste regarding the timing stuff. I bet you got some important stuff to do.
Keep up the good work