A running μScheme program continually allocates fresh locations. How are they supplied? Memory is limited, and malloc will eventually run out. Memory can be recovered using free, but if a programmer must call free, as in C and C++, they risk memory errors: leaks, locations that are freed multiple times, and misuse of freed locations (so-called dangling-pointer errors). Memory errors can make a program crash—or, worse, silently produce wrong answers. But in languages like μScheme, full Scheme, Java, and JavaScript, which are memory-safe, such errors are impossible. The errors are prevented because the implementation of μScheme, not the μScheme programmer, figures out when it is safe to reuse a location. The techniques used to reuse locations safely are demonstrated in this chapter.
Review the options below to login to check your access.
Log in with your Cambridge Higher Education account to check access.
If you believe you should have access to this content, please contact your institutional librarian or consult our FAQ page for further information about accessing our content.