dynamic memory allocation considered beneficial

Wietse Venema (wietse@PORCUPINE.ORG)
Thu, 05 Mar 1998 15:51:13 -0500

D. J. Bernstein writes:
> Dynamic allocation _saves_ memory.
>
> If you've set aside a 4096-byte static buffer for a line of text that's
> only 60 bytes long, for example, then you're wasting four thousand bytes
> of memory.
>
> Do the same thing in fifty different functions, in ten running programs,
> and suddenly you've wasted two megabytes of memory. Poor engineering.
> Ever wonder why your system is swapping?
>
> It is much better to give those 2 megabytes back to the user. That's
> exactly what dynamic allocation does: your program grabs only as much
> memory as it needs.

For the record, up to this point I am in full agreement with Mr.
Bernstein. We differ in opinion on details, namely how to control
the total amount of memory that a process can grab in this manner.

And, I suppose, we differ in opinion on a couple other things too.
But none of the differences is worth discussion.

Wietse