dynamic memory allocation considered beneficial

From: Wietse Venema (wietseat_private)
Date: Thu Mar 05 1998 - 12:51:13 PST

  • Next message: stanislav shalunov: "another /tmp race: `perl -e' opens temp file not safely"

    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
    



    This archive was generated by hypermail 2b30 : Fri Apr 13 2001 - 13:44:22 PDT