In the last episode (May 20), Till Plewe said:
> My problem is essentially that freeing large numbers of small chunks
> of memory can be very slow. I have run into this problem twice so
> far.

Do you have a testcase?  The attached program mallocs 1 million
128-byte blocks, then frees them.  With MALLOC_OPTIONS set to jz (i.e.
no filling of freed memory), it takes .184 seconds to free them all. 
With it set to J, it takes 1 second.

CPU: Intel Pentium III (909.96-MHz 686-class CPU)
 
-- 
        Dan Nelson
        [EMAIL PROTECTED]
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <sys/resource.h>

#define NUM 1048576
#define SIZE 128

void *mypointers[NUM];
struct timeval elap;
struct rusage r_s, r_e;

int main(void)
{
        int i;

        printf("malloc:");
        fflush(stdout);
        for (i = 0; i < NUM; i++)
        {
                mypointers[i] = malloc(SIZE);
        }
        printf("done.\nfree:");
        fflush(stdout);
        getrusage(RUSAGE_SELF, &r_s);
        for (i = 0; i < NUM; i++)
        {
                free(mypointers[i]);
        }
        getrusage(RUSAGE_SELF, &r_e);
        timersub(&r_e.ru_utime, &r_s.ru_utime, &elap);
        printf("done. %ld.%06ld\n", elap.tv_sec, elap.tv_usec);
        return 0;
}
_______________________________________________
[EMAIL PROTECTED] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to