[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: SWAP or swap



> Can anyone verify this.. I don't wanna waste disk space if it's not gonna be
> used.  Thanks to you George.

if you dont beleive it, run this program:
------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>

void main () {
        unsigned long int *j,i;
        double total=0;

        for (i=1;i<500000000;i++) {
                total=total+sizeof(i);
                j=malloc(sizeof(i));
                if(j==NULL) {
                        printf("malloc() failed, quitting\n");
                        break;
                }
                else
                *j=random()%5000;
        }
        printf("done, sleeping\n");
        sleep(600);
}
-------------------------------------------------------------------------

I wrote this one day when I was really bored.. :)  Just paste it into a
file, run gcc filename, and run ./a.out, and watch free or top..

Attachment: pgpdaaHLhj7vF.pgp
Description: PGP signature


Reply to: