cs431
cs431 copied to clipboard
[Homework 3] Core Arc (due: 2024-04-14 23:59:59)
Implement a simplified version of Arc.
-
Read this manual for general advice on homework.
-
Use skeleton code as a starting point, and fill out
todo!()
.- IMPORTANT: don't fork this repository. It'll be public!
-
Submit your code here.
-
IMPORTANT: Only the last submission counts. Please make sure the last line of the "log" says "Score: ?? / ??".
When running tests with cargo_asan test --doc arc, I encountered an error indicating a memory leak. However, in the case of try_unwrap, if the Arc is unique, isn't it expected to have a memory leak?
Without looking at real code, it is really difficult to find out the reason for having memory leaks since there are lots of sources for memory leaks. But even if Arc
is unique, your implementation may have memory leak if you incorrectly understand Rust's semantics for dropping an object. For example, one example of incorrect implementation of try_unwrap
might leave some contents of Arc
(e.g. count
) unallocated forever even if try_unwrap
successfully returns the inner value and the inner value has been dropped by the caller.