Did you even read that thread? Especially the comment by jsmith:
Normal behavior. The data you are writing (to disk) is being written to the page cache as well, and the kernel will expand the page cache as long as there is memory available (to a certain point).
The memory is being "used" by the kernel for the disk cache, but that's not a problem because the kernel can and will free up memory used by the disk cache when memory is needed by other things.

Why not just simply do something like this to ensure you write everything in your buffer:

Code:
// char buf[...]; // the buffer to write
// size_t size; // the size of the buffer
size_t start = 0;
do {
  ssize_t n = write(fd, buf + start, size - start);
  if (n < 0) {
    // Write error. errno is set. Handle it however you want to.
  }
  start += n;
} while (start < size);
And fwrite automatically writes out as much as possible unless it encounters a write error (it does essentially what the above code does). So if you have a FILE handle, use fwrite and don't worry about it. If you only have a file descriptor and want to write everything out despite partial writes, use something like the above code.