Region-based Memory Management

This paper describes a memory management discipline for programs that perform dynamic memory allocation and de-allocation. At runtime, all values are put intoregions. The store consists of a stack of regions. All points of region allocation and de-allocation are inferred automatically, using a type and effect based program analysis. The scheme does not assume the presence of a garbage collector. The scheme was first presented in 1994 (M. Tofte and J.-P. Talpin,in“Proceedings of the 21st ACM SIGPLAN?SIGACT Symposium on Principles of Programming Languages,” pp. 188?201); subsequently, it has been tested in The ML Kit with Regions, a region-based, garbage-collection free implementation of the Standard ML Core language, which includes recursive datatypes, higher-order functions and updatable references L. Birkedal, M. Tofte, and M. Vejlstrup, (1996),in“Proceedings of the 23 rd ACM SIGPLAN?SIGACT Symposium on Principles of Programming Languages,” pp. 171?183. This paper defines a region-based dynamic semantics for a skeletal programming language extracted from Standard ML. We present the inference system which specifies where regions can be allocated and de-allocated and a detailed proof that the system is sound with respect to a standard semantics. We conclude by giving some advice on how to write programs that run well on a stack of regions, based on practical experience with the ML Kit.

[1]  Joannes M. Lucassen Types and Effects Towards the Integration of Functional and Imperative Programming. , 1987 .

[2]  Lars Birkedal,et al.  From region inference to von Neumann machines via region representation inference , 1996, POPL '96.

[3]  Thomas P. Murtagh,et al.  Lifetime analysis of dynamically allocated objects , 1988, POPL '88.

[4]  Niels Hallenberg A Region Profiler for a Standard ML compiler based on Region Inference , 1996 .

[5]  Flemming Nielson,et al.  Higher-order concurrent programs with finite communication topology (extended abstract) , 1994, POPL '94.

[6]  Paul Hudak A semantic model of reference counting and its abstraction (detailed summary) , 1986, LFP '86.

[7]  Friedrich L. Bauer,et al.  Revised report on the algorithm language ALGOL 60 , 1963, CACM.

[8]  John McCarthy,et al.  Recursive functions of symbolic expressions and their computation by machine, Part I , 1959, Commun. ACM.

[9]  Mads Tofte,et al.  A theory of stack allocation in polymorphically typed languages , 1993 .

[10]  Andrew W. Appel,et al.  Compiling with Continuations , 1991 .

[11]  Henry Lieberman,et al.  A real-time garbage collector based on the lifetimes of objects , 1983, CACM.

[12]  Donald E. Knuth,et al.  fundamental algorithms , 1969 .

[13]  David K. Gifford,et al.  Polymorphic effect systems , 1988, POPL '88.

[14]  Martin Elsman,et al.  An Optimizing Backend for the ML Kit Using a Stack of Regions , 1995 .

[15]  Simon L. Peyton Jones,et al.  Imperative functional programming , 1993, POPL '93.

[16]  Mark Halpern Variable-width tables with binary-search facility , 1958, CACM.

[17]  Alexander Aiken,et al.  Better static memory management: improving region-based analysis of higher-order languages , 1995, PLDI '95.

[18]  E. Dijkstra,et al.  Recursive Programming , 1960 .

[19]  Peter Naur Appendix: Revised report on the algorithmic language ALGOL 60 , 1964 .

[20]  Michael P. Georgeff,et al.  Transformations and reduction strategies for typed lambda expressions , 1984, ACM Trans. Program. Lang. Syst..

[21]  Donald Ervin Knuth,et al.  The Art of Computer Programming , 1968 .

[22]  S. L. Graham,et al.  List Processing in Real Time on a Serial Computer , 1978 .

[23]  Robin Milner,et al.  A Theory of Type Polymorphism in Programming , 1978, J. Comput. Syst. Sci..

[24]  LiebermanHenry,et al.  A real-time garbage collector based on the lifetimes of objects , 1983 .

[25]  Robin Milner,et al.  Principal type-schemes for functional programs , 1982, POPL '82.

[26]  Rosen Saul,et al.  Programming systems and languages , 1966 .

[27]  Katsuro Inoue,et al.  Analysis of functional programs to detect run-time garbage cells , 1988, TOPL.

[28]  Alan Mycroft,et al.  Polymorphic Type Schemes and Recursive Definitions , 1984, Symposium on Programming.

[29]  Pierre Jouvelot,et al.  Algebraic reconstruction of types and effects , 1991, POPL '91.

[30]  Pierre Jouvelot,et al.  Polymorphic type, region and effect inference , 1992, Journal of Functional Programming.

[31]  Robin Milner,et al.  Definition of standard ML , 1990 .

[32]  Philip Wadler,et al.  Once upon a type , 1995, FPCA '95.