memset example

This is just a quick note so I don’t forget. If you don’t run a memset, the memory will only be allocated, but not shown as being used in the OS.

int main() {
  int i = 1;

  while(i++ < 10) {
    void *m = malloc(100*1024*1024);
    memset(m,0,100*1024*1024);
    sleep(1);
  }
  return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.