Fast allocation and deallocation of memory based on object lifetimes
暂无分享,去创建一个
Dynamic storage‐management algorithms are based either on object sizes or object lifetimes. Stack allocation, which is based on object lifetimes, is the most efficient algorithm, but severely restricts object lifetimes and creation times. Other algorithms based on object sizes, such as first fit and related algorithms, permit arbitrary lifetimes but cost more. More efficient variations capitalize on application‐specific characteristics. Quick fit, for example, is more efficient when there are only a few object sizes. This paper describes a simple algorithm that is very efficient when there are few object lifetimes. In terms of instructions executed per byte allocated, the algorithm is almost half the cost of quick fit and less than twice the cost of stack allocation. Space for all objects with the same lifetime is allocated from a list of large arenas, and the entire list is deallocated at once. An implementation in ANSI C is included.
[1] Donald E. Knuth,et al. The Art of Computer Programming, Volume I: Fundamental Algorithms, 2nd Edition , 1997 .
[2] Andrew W. Appel,et al. Garbage Collection can be Faster than Stack Allocation , 1987, Inf. Process. Lett..
[3] William A. Wulf,et al. An efficient algorithm for heap storage allocation , 1988, SIGP.
[4] Jacques Cohen,et al. Garbage Collection of Linked Data Structures , 1981, CSUR.