The following code will give you the memory footprint of a process
#define SM_BUFF_SIZE_PI 100
int getProcessSize() {
char buffer[SM_BUFF_SIZE_PI];
int memSize;
FILE *fileStream;
pid_t id = getpid();
// Command to execute - uses ps to get the current size and finds the
// size for the particular process
sprintf(buffer, "ps -eo vsz,vsize,pid | grep %d | ", id);
strcat(buffer, " awk '{printf(\"%s\\n\", $1);}'");
// Creates a process to get the information and write the result to a
// file stream
fileStream = popen(buffer, "r");
fscanf(fileStream, "%d", &memSize);
fclose(fileStream);
return memSize;
}