Hostname: page-component-6766d58669-r8qmj Total loading time: 0 Render date: 2026-05-16T12:24:46.320Z Has data issue: false hasContentIssue false

Empirical and analytic study of stack versus heap cost for languages with closures

Published online by Cambridge University Press:  07 November 2008

Andrew W. Appel
Affiliation:
Department of Computer Science, Princeton University, Princeton, NJ 08544-2087, USA
Zhong Shao
Affiliation:
Department of Computer Science, Princeton University, Princeton, NJ 08544-2087, USA
Rights & Permissions [Opens in a new window]

Abstract

Core share and HTML view are not available for this content. However, as you have access to this content, a full PDF is available via the 'Save PDF' action button.

We present a comprehensive analysis of all the components of creation, access and disposal of heap-allocated and stack-allocated activation records. Among our results are:

•Although stack frames are known to have a better cache read-miss rate than heap frames, our simple analytical model (backed up by simulation results) shows that the difference is too trivial to matter.

•The cache write-miss rate of heap frames is very high; we show that a variety of miss-handling strategies (exemplified by specific modern machines) can give good performance, but not all can.

•Stacks restrict the flexibility of closure representations (for higher-order functions) in important (and costly) ways.

•The extra load placed on the garbage collector by heap-allocated frames is small.

•The demands of modern programming languages make stacks complicated to implement efficiently and correctly.

Overall, the execution cost of stack-allocated and heap-allocated frames is similar; but heap frames are simpler to implement and allow very efficient first-class continuations.

Information

Type
Articles
Copyright
Copyright © Cambridge University Press 1996
Submit a response

Discussions

No Discussions have been published for this article.