I am writing a C program in which I need to flush my memory. I would like know if there is any UNIX system command to flush memory cache. Also, it is a requirement for my project which involves calculating the time taken for my logic, therefore I need to flush the cache. Can someone be kind enough to help?
I'm going to assume that you mean a known section of memory that you have a pointer to, and that you know the size of the memory.
You cannot "clear out" memory. All you can do is put a new value in it. Commonly in C and C++ this is done using memset. Here is how to set some memory to zero.