title: Problem with free() on structs in C. It doesn't reduce memory usage
body: <p>I'm having a problem with free() on a struct in my C program. When I look at /proc//statm before and after the free it doesn't seem to reduce. Am I using free() wrong in this case, or am I reading /proc//statm wrong?</p>
  
  <p>Here is a test case which yields the problem:</p>
  
  <pre><code>struct mystruct {
      unsigned int arr[10000];
  };
  
  void mem() {
      char buf[30];
      snprintf(buf, 30, "/proc/%u/statm", (unsigned)getpid());
      FILE* pf = fopen(buf, "r");
      if (pf) {
          unsigned size; //       total program size
          unsigned resident;//   resident set size
          unsigned share;//      shared pages
          unsigned text;//       text (code)
          unsigned lib;//        library
          unsigned data;//       data/stack
          unsigned dt;//         dirty pages (unused in Linux 2.6)
          fscanf(pf, "%u %u %u %u %u %u", &amp;size, &amp;resident, &amp;share, &amp;text, &amp;lib,         &amp;data);
          printf("Memory usage: Data = %d\n", data*sysconf(_SC_PAGESIZE));
      }
      fclose(pf);
  }
  
  int main(int argc, char **argv) {
      mem();
      struct mystruct *foo = (struct mystruct *)malloc(sizeof(struct mystruct));
      mem();
      free(foo);
      mem();
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>Memory usage: Data = 278528
  Memory usage: Data = 282624
  Memory usage: Data = 282624
  </code></pre>
  
  <p>When I would expect it to be:</p>
  
  <pre><code>Memory usage: Data = 278528
  Memory usage: Data = 282624
  Memory usage: Data = 278528
  </code></pre>
  
  <p>I've done a similar test with malloc'ing a (char *), then free'ing it and it works fine. Is there something special about structs?</p>