0

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.

4
  • 3
    valgrind is the standard for checking for memory leaks, I think. Jan 27, 2016 at 8:50
  • Valgrind indeed, however it is so much more useful when the program is compiled with debug information. Jan 27, 2016 at 8:54
  • My intention is that the measurement shall be non destructive. I've not used Valgrind myself, but I've understood that it affects the performance of the measured process considerably. My intention is to make a rudimentary check on a nonaffected process(es). But maybe the uncertainties are too big to get anything out of the ps command? Jan 27, 2016 at 9:22
  • For an embedded system, you'll want to make sure beforehand nothing goes wrong. Use 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.
    – vonbrand
    Jan 27, 2016 at 11:24

0

You must log in to answer this question.

Browse other questions tagged .