Mail Archives: djgpp/1996/08/12/08:57:37
Leath Muller wrote:
> At the moment, I use several doubly-linked lists to store information used
> by my program...and at the end, go to the trouble to free all the nodes using
> recursive freeing subroutines...
>For large chunks of memory, there is nothing wrong with this.
If you do many mallocs on small quantities of memory, you can improve a
little on that by mallocking big chunks of memory (what big is depends on
your program) that you will "dispatch" as you need. It wastes a bit of
memory, but saves a lot of freeing and mallocking time.
Also, if you do not need too much memory (several kbytes, 10s of kbytes,
but not 100s of kbytes) you can consider using alloca(), which allocates
data from the stack. The good thing with it is that your data will be
automatically freed when the function you call alloca() in is left, and
also it is very fast. The bad thing is that stack length is limited to
256kbytes, so you should not use it for big chunks of data.
Hope this helps,
Regards,
F. Charton
- Raw text -