At 2006-03-02 22:24:17+0000, Nik Clayton writes:
> I'm failing to understand how getrusage() works, which is a bit perplexing,
> because it doesn't seem like it would be terribly complicated.

ru_maxrss is the maximum resident set size, not the heap size.
malloc(big) doesn't grow the resident set.  Touching the memory you
have allocated will grow the resident set.  Try this:

        getrusage(RUSAGE_SELF, &ru);
        printf("%lu\n", ru.ru_maxrss);
        p = malloc(SIZE);
        assert(p)
        getrusage(RUSAGE_SELF, &ru);
        printf("%lu\n", ru.ru_maxrss);
        for (i=0; i<SIZE; ++i) {
                p[i] = 0;
        }
        getrusage(RUSAGE_SELF, &ru);
        printf("%lu\n", ru.ru_maxrss);

Nick B
_______________________________________________
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to