Skip to main content
Log in

Fast allocation and deallocation with an improved buddy system

  • Published:
Acta Informatica Aims and scope Submit manuscript

Abstract.

We propose several modifications to the binary buddy system for managing dynamic allocation of memory blocks whose sizes are powers of two. The standard buddy system allocates and deallocates blocks in \(\Theta(\lg n)\) time in the worst case (and on an amortized basis), where n is the size of the memory. We present three schemes that improve the running time to O(1) time, where the time bound for deallocation is amortized for the first two schemes. The first scheme uses just one more word of memory than the standard buddy system, but may result in greater fragmentation than necessary. The second and third schemes have essentially the same fragmentation as the standard buddy system, and use \(O(2^{(1 + \sqrt{\lg n}) \lg \lg n})\) bits of auxiliary storage, which is \(\omega(\lg^k n)\) but \(o(n^\varepsilon)\) for all \(k \geq 1\) and \(\varepsilon > 0\). Finally, we present simulation results estimating the effect of the excess fragmentation in the first scheme.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Barkley, R.E., Lee, T.P. (1989) A lazy buddy system bounded by two coalescing delays per class. Operating Systems Review Dec.: 167-176

  2. Brodnik, A. (1993) Computation of the least significant set bit. In: Proceedings of the 2nd Electrotechnical and Computer Science Conference, Portoroz, Slovenia

  3. Bromley, A.G. (1976) An improved buddy method for dynamic storage allocation. In: Proceedings of the 7th Australian Computer Conference, pp. 708-715

  4. Bromley, A.G. (1980) Memory fragmentation in buddy methods for dynamic storage allocation. Acta Informatica 14: 107-117

    Google Scholar 

  5. Burton, W. (1976) A buddy system variation for disk storage allocation. Communications of the ACM 19(7): 416-417

    Google Scholar 

  6. Chowdhury, S.K., Srimani, P.K.: Worst case performance of weighted buddy systems. Acta Informatica 24(5): 555-564

    Google Scholar 

  7. Cranston, B., Thomas, R. (1975) A simplified recombination scheme for the Fibonacci buddy system. Communications of the ACM 18(6): 331-332

    Google Scholar 

  8. Demaine, E.D., Munro, J.I. (1999) Fast Allocation and Deallocation with an Improved Buddy System. In: Proceedings of the 19th Conference on the Foundations of Software Technology and Theoretical Computer Science (FST & TCS’99), Lecture Notes in Computer Science, vol. 1738. Chennai, India, December 13-15, 1999, pp. 84-96

  9. Hinds, J.A. (1975) Algorithm for locating adjacent storage blocks in the buddy system. Communications of the ACM 18(4): 221-222

    Google Scholar 

  10. Hirschberg, D.S. (1973) A class of dynamic memory allocation algorithms. Communications of the ACM 16(10): 615-618

    Google Scholar 

  11. Kaufman, A. (1984) Tailored-list and recombination-delaying buddy systems. ACM Transactions on Programming Languages and Systems 6(1): 118-125

    Google Scholar 

  12. Knowlton, K.C. (1965) A fast storage allocator. Communications of the ACM 8(10): 623-625

    Google Scholar 

  13. Knowlton, K.C. (1966) A programmer’s description of L6. Communications of the ACM 9(8): 616-625

    Google Scholar 

  14. Knuth, D.E. (1968) Dynamic storage allocation. In: The art of computer programming, vol. 1, Sect. 2.5, pp. 435-455. Addison-Wesley

  15. Koch, P.D.L. (1987) Disk file allocation based on the buddy system. ACM Transactions on Computer Systems 5(4): 352-370

    Google Scholar 

  16. Lee, T.P., Barkley, R.E. (1989) Design and evaluation of a watermark-based lazy buddy system. Performance Evaluation Review 17(1): 230

    Google Scholar 

  17. Lee, T.P., Barkley, R.E. (1989) A watermark-based lazy buddy system for kernel memory allocation. In: Proceedings of the 1989 Summer USENIX Conference, June, pp. 1-13

  18. Lloyd, E.L., Loui, M.C. (1985) On the worst case performance of buddy systems. Acta Informatica 22(4): 451-473

    Google Scholar 

  19. McKusick, M.K., Bostic, K., Karels, M.J., Quarterman, J.S. (1996) The design and implementation of the 4.4 BSD operating system. Addison-Wesley

  20. Page, I.P., Hagins, J. (1986) Improving the performance of buddy systems. IEEE Transactions on Computers C-35(5): 441-447

    Google Scholar 

  21. Peterson, J.L., Norman, T.A. (1977) Buddy systems. Communications of the ACM 20(6): 421-431

    Google Scholar 

  22. Purdom, P.W. Jr., Stigler, S.M. (1970) Statistical properties of the buddy system. Journal of the ACM 17(4): 683-697

    Google Scholar 

  23. Russell, D.L. (1977) Internal fragmentation in a class of buddy systems. SIAM Journal on Computing 6(4): 607-621

    Google Scholar 

  24. Shen, K.K., Peterson, J.L. (1974) A weighted buddy method for dynamic storage allocation. Communications of the ACM 17(10): 558-562. See also the corrigendum in 18(4): 202 (Apr. 1975)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Gerth Stølting Brodal.

Additional information

Received: 4 May 2003, Published online: 22 December 2004

Gerth Stølting Brodal: Supported by the Carlsberg Foundation (contract number ANS-0257/20). Partially supported by the Future and Emerging Technologies Programme of the EU under contract number IST-1999-14186 (ALCOM-FT). Basic Research in Computer Science, www.brics.dk, funded by the Danish National Research Foundation.

Erik D. Demaine: Partially supported by the Natural Science and Engineering Research Council of Canada (NSERC).

J. Ian Munro: Supported by the Natural Science and Engineering Research Council of Canada (NSERC) and the Canada Research Chair in Algorithm Design.

This paper includes several results that appeared in preliminary form in the Proceedings of the 19th Conference on the Foundations of Software Technology and Theoretical Computer Science (FST & TCS’99) [8].

Rights and permissions

Reprints and permissions

About this article

Cite this article

Brodal, G.S., Demaine, E.D. & Munro, J.I. Fast allocation and deallocation with an improved buddy system. Acta Informatica 41, 273–291 (2005). https://doi.org/10.1007/s00236-004-0159-6

Download citation

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00236-004-0159-6

Keywords

Navigation