我有以下代码,想知道当 iOS 重新收集分配的内存时会发生什么。p1 指向的内存是否会在之后自动释放,尽管它现在指向不同的内存?而且 p2 指向的内存也会被自动释放,因为 p1 在语义上意味着在开始时指向自动释放的内存?
NSMutableArray *p1 = [NSMutableArray arrayWithCapacity:10];
NSMutableArray *p2 = [[NSMutableArray alloc] init];
// what will happen to the memory p1 and p2 point to
// after the following assignment, and at later stage?
p1 = p2;