I have an automatic program checker installed, which allows to run some tests against (student) code with respect of memory and time limits. Currently all programs written in c++ are run in
valgrind environment to expose memory allocation problems. As well known,
valgrind significantly slows down program execution. But in many cases it does not matter because (student) programs in other languages (like java or python) have similar run time.
Unfortunately, I've run into a case when runtime of C++ increases significantly and I need faster drop-in replacement for valgrind.
I've some restrictions/abilities for tool:
- The tool should work at the start of the program (not to be attached after start).
- It should detect most memory allocation/leaks problems.
- The program should exit with some non-zero code if a problem with memory is detected.
- The source code can be preprocessed with some tool.
- It should be faster than valgrind.
- g++ or linux-only solutions are ok.
There is also and old similar question on SO: https://stackoverflow.com/questions/18455698/lightweight-memory-leak-debugging-on-linux But I have a bit different situation and solution there did not work for me.
- GNU libc built-in malloc debugging (with LD_PRELOAD) - no auto analysis, only log
- memleax - only allows to be attached to running program, minimum window is one second - too high.
- LeakTracer - seems like it, but no non-zero code (but I've already done a PR) and sometimes it has false positives
- bdwgc, but same problems with non-zero exit code and doesn't work without code editing (which may be non trivial for c++ stl containers).
This post was originally posted on StackOverflow, but deleted as offtopic.