I plan to use something like
ps -A --sort -rss -o comm,rss,sz,vsz
to detect memory leaks.
I plan to run the command before and after test cases in an embedded system, and my hope it that the system will be in idle state at the measurements. I've tried a bit with the VSZ figure, but I'm a bit uncertain about the internal handling of virtual memory.
Can I trust that the VSZ shows the current virtual memory usage, or can there be non used (totally freed) pages in that figure?
Is VSZ the best indicator of memory leaks, or shall I use another measure? RSS shows only the resident memory, and that does not necessarily indicate memory leaks, does it?
Is the internal linux memory handling far to complex to be able to detect memory leaks in this way (by help of ps)?
I need to use some external measurement method. I can't use for instance mtrace etc.
valgrind
offline, compile with full warnings and make sure they are harmless, search for programs that analyse source code for problems, consider using garbage collection/reference counting to automatize memory handling.