Mail Archives: djgpp/2002/01/20/13:45:19
John wrote:
>
> As a follow-up, I just did a test inserting 500,000 nodes of a linked list,
> this involves setting the previous and next pointers and the data item,
> amongst other things. This took 280ms. (I have quite a fast machine)
>
> To free the same 500,000 nodes it takes 9,236ms, and the code in this case
> is only walking through the list and calling free().
I think the DJGPP implementation of malloc is optimized for allocations more
than deallocations. But you can easily see where're the hot spots if you
compile malloc.c from the library with -pg, link with -pg, and then profile
the test program. That's the beauty of Free Software: the sources are
freely available to study and scrutinize.
I have no idea what does lcc use in its library.
Btw, a program should not need to free its heap before it exits. The OS
will take care about it.
- Raw text -