I've got a software running on Linux that is leaking memory. It's an embedded system so I don't have a lot of debugging tools so I'm using printf's.
Short of doing something like 'popen()'ing a call to 'cat /proc/meminfo' and scanning for the MemFree line, is there a way I can put this information in a printf?
At present I'm doing something akin to:
# ./myprogram &
# for (( c=0; c<99; c++)) do echo --- $c --- && cat /proc/meminfo | grep MemFree: && sleep 30; done;
Which is okay, but I was wondering if there was a better way.
Edit: The four responses so far aren't quite what I was looking for, I wasn't specific enough.
It appears my program isn't the cause of the memory leak; regardless I was looking to see if I could add some 'c' code that would see/report the free memory in the system, not how much memory my code (process) is using.