Q:

Why my program occupies 32KB and not 11200B (Valgrind's massif)

The n-body program does this at the begining:
  real4 *pin  = (real4*)malloc(n * sizeof(real4));
  real4 *pout = (real4*)malloc(n * sizeof(real4));
  real3 *v    = (real3*)malloc(n * sizeof(real3));
  real3 *f    = (real3*)malloc(n * sizeof(real3));

the total size of this should be (if n = 100): 100*32 + 100*32 + 100*24 + 100*24 = 11200B but with Valgrind's massif I have this:

A:

I am not fammilliar with massif, but when talking about heap memory, there are two numbers that are interesting, how much memory has the allocator requested from the OS, and how much has the allocator given to your program through malloc(). If your program has requested ~10K of bytes, it is reasonable to think that the allocator may have requested a round number like 32K from the OS. The allocator typically request memory in large blocks from the OS since kernel calls are slow. (and a few other reasons)
So I would guess that the 32K that you are seeing, is what the allocator has aquired from the OS, ready to be given to your program through any additional malloc() that may happen.

