fprintf causing MemFree to decrease

127 Views Asked by At

I have a thread logging variables' values to a file, something similar to this:

fp = fopen("log.txt", "a");

fprintf(fp, "%d,", var1);
fprintf(fp, "%d,", var2);
fprintf(fp, "%d,", var3);
...
fprintf(fp, "\n");

fclose(fp);

I noticed that MemFree in /proc/meminfo is rapidly decreasing, I suspect because of my output being buffered. To my suprise, MemFree is not recovered after killing the process. This lead me to these questions:

  1. Can having low (or no) MemFree cause issues?
  2. How can I avoid "loosing" memory?

Thank you in advance.

0

There are 0 best solutions below