a) Identify the two memory management defects in the code. Point out the line numbers where the defects occur, and explain the nature of the defects. (b) If we introduce a naive reference counting garbage collector into the language without other protections, would each of the defects still occur? Explain why or why not for each case. (c) C and C++ whose memory is managed by the programmer are notorious for their error-prone memory management. Yet, these languages are still widely used in systems pro- gramming due to languages with garbage collection being too slow for performance critical components. Recently, the Rust programming language has gained popularity in systems pro- gramming for being memory safe while maintaining good performance. Read about the Rust programming language and briefly explain in your own words how it achieves memory safety while maintaining good performance.
(a) Identify the two memory management defects in the code. Point out the line numbers
where the defects occur, and explain the nature of the defects.
(b) If we introduce a naive reference counting garbage collector into the language without
other protections, would each of the defects still occur? Explain why or why not for each
case.
(c) C and C++ whose memory is managed by the programmer are notorious for their
error-prone memory management. Yet, these languages are still widely used in systems pro-
gramming due to languages with garbage collection being too slow for performance critical
components. Recently, the Rust programming language has gained popularity in systems pro-
gramming for being memory safe while maintaining good performance. Read about the Rust
programming language and briefly explain in your own words how it achieves memory
safety while maintaining good performance.
Step by step
Solved in 4 steps