The Implementer’s Dilemma: A Mathematical Model of Compile Time Garbage Collection

  • Simon B. Jones
  • Andrew S. Tyas
Part of the Workshops in Computing book series (WORKSHOPS COMP.)


Optimization by compile time garbage collection is one possible weapon in the functional language implementer’s armoury for combatting the excessive memory allocation usually exhibited by functional programs. It is an interesting idea, but the practical question of whether it yields benefits in practice has still not been answered convincingly one way or the other.

In this short paper we present a mathematical model of the performance of straightforward versions of mark-scan and copying garbage collectors with programs optimized for explicit deallocation. A mark-scan heap manager has a free list, whereas a copying heap manager does not — herein lies the dilemma, since a copying garbage collector is usually considered to be faster than a mark-scan, but it cannot take advantage of this important optimization.

For tract ability we consider only heaps with fixed cells. The results reported show that the garbage collection scheme of choice depends quite strongly on the heap occupancy ratio: the proportion of the total heap occupied by accessible data structures averaged over the execution of the program. We do not know what typical heap occupancy ratios are, and so are unable to make specific recommendations, but the results may be of use in tailoring applications and heap management schemes, or in controlling schemes where the heap size varies dynamically.

An important result arising from the work reported here is that when optimizing for explicit deallocation, a very large proportion of cell releases must be optimized before very much performance benefit is obtained.


Garbage Collection Free List Occupancy Ratio Heap Size Heap Management 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. [1]
    A.W. Appel. Garbage collection can be faster than stack allocation. Information Processing Letters, 25(4):275–279, June 1987.CrossRefGoogle Scholar
  2. [2]
    J. Heyman. A comprehensive analytical model for garbage collection algorithms. ACM SIGPLAN Notices, 26(8), August 1991.Google Scholar
  3. [3]
    S.B. Jones and D. Le Métayer. Compile-time garbage collection by sharing analysis. In Proceedings of the Fourth International Conference on Functional Programming Languages and Computer Architecture, pages 54–74, 1989.Google Scholar
  4. [4]
    P. Sansom. Combining copying and compacting garbage collection. In R. Heldal, C.K. Hoist, and P. Wadler, editors, 1991 Glasgow Workshop on Functional Programming. Springer-Verlag, Workshops in Computing, August 1991.Google Scholar
  5. [5]
    A.S. Tyas. An investigation into the optimization of garbage collection within functional languages. Final Year Dissertation, Department of Computing Science and Mathematics, University of Stirling, April 1993.Google Scholar

Copyright information

© British Computer Society 1994

Authors and Affiliations

  • Simon B. Jones
    • 1
  • Andrew S. Tyas
    • 1
  1. 1.Department of Computing Science and MathematicsUniversity of StirlingStirlingScotland

Personalised recommendations