1

How do you test the swap space using C ?

view story
linux-howto

http://crunchbanglinux.org – Original source code :#include <stdlib.h> #include <stdio.h> #include <string.h> int main(int argc, char** argv) { int max = -1; int mb = 0; char* buffer; if(argc > 1) max = atoi(argv[1]); while((buffer=malloc(1024*1024)) != NULL && mb != max) { memset(buffer, 0, 1024*1024); mb++; printf("Allocated %d MB\n", mb); sleep(1); } return 0; }I changed it.It works and it's collecting 16 mb of memory in second.#include <stdlib.h> #include <stdio.h> #include <string.h> (HowTos)