On Mon, Mar 07, 2016 at 09:15:06PM +0100, Florian Pelz wrote:
Sorry, I didn't express myself properly. I didn't mean to criticize free. What I meant to say was that the time it takes to parse /proc/meminfo or free is negligible. It doesn't need to be any more efficient. free parses /proc/meminfo. libgtop parses /proc/meminfo. Querying the information probably takes much more time than parsing it.
Your suggestion to use free may indeed be useful if the original poster wants parsing to be slightly simpler and does not mind the additional dependency. My impression was that they considered parsing to be too inefficient.
Don't worry. Actually, I understood your point perfectly. I suggested free only because I originally supposed the OP wanted his program to contain as little code as possible in his program, and didn't want to parse the file himself.