Environment and memory management