Most implementations of
free use memory-management algorithms that are necessarily based on the sizes of objects. The first-fit algorithm used in the previous chapter is an example. In some applications, deallocations are grouped and occur at the same time. Graphical user interfaces are an example. Space for scroll bars, buttons, and so forth, is allocated when a window is created, and deallocated when the window is destroyed. A compiler is another example.
lcc, for example, allocates memory as it compiles a function and deallocates all of that memory at once when it finishes compiling the function.
Memory-management algorithms based on the lifetimes of objects are often better for these kinds of applications. ...