Insertion and Compaction Algorithms in Sequentially Allocated Storage

Among the more difficult combinatorial problems in computer science are those occurring in dynamic storage allocation. We investigate the handling of memory conflicts occurring when a request for a block of storage is received, but no one region of available space is large enough due to fragmentation of storage. For arbitrary block sizes, we show that it is NP-hard to find a minimal cost reallocation of memory that will allow insertion of a new block. Therefore, we focus on the “bay restaurant” model studied by Robson, in which requests are for only one or two units of memory. We give a polynomial time algorithm for minimal cost insertions of batches of blocks and for minimal cost memory compaction. We show that the cost of inserting p blocks one at a time, i.e. on-line, is no worse than \[ \left\lfloor 2\left( \frac{3}{2} \right)^{\lceil \log p \rceil } - 1 \right\rfloor \] times the minimal cost of inserting the blocks in one batch, i.e. off-line. For p a power of two, this bound is tight.