这个因为 [NSOperationQueue mainQueue] 并非单例,这个写法非常像单例,然后我运行下,发现不管在什么情况下 [NSOperationQueue mainQueue] 返回的地址都是相同的进一步证明了我的猜想,让后我下载了Gnustep源码,参考了下[NSOperationQueue mainQueue]和[NSNotificationCenter defaultCenter]写法一样都是单例,那么怎么确认是否有循环引用呢, 我参考了下NSNotificationCenter源码 <img width="503" alt="screenshot" src="https://user-images.githubusercontent.com/21049737/124603335-6a066300-de9c-11eb-8f1c-2821674891cd.png"> <img width="656" alt="screenshot" src="https://user-images.githubusercontent.com/21049737/124603333-6a066300-de9c-11eb-96ca-637d19db2a4b.png"> <img width="491" alt="screenshot" src="https://user-images.githubusercontent.com/21049737/124603612-b18cef00-de9c-11eb-92aa-9d5bc538ba10.png"> 这就证明了 <img width="1013" alt="screenshot" src="https://user-images.githubusercontent.com/21049737/124603778-ded99d00-de9c-11eb-8767-82bcf162ebde.png"> 然后参考addOperationWithBlock源码 <img width="621" alt="screenshot" src="https://user-images.githubusercontent.com/21049737/124604182-47287e80-de9d-11eb-9430-12d531b6a98c.png"> <img width="594" alt="screenshot" src="https://user-images.githubusercontent.com/21049737/124604183-47287e80-de9d-11eb-9425-4c07c39db3c0.png"> 所以[NSOperationQueue mainQueue]虽然是单例,但是不持有block,不会造成循环引用,传递完成就销毁了,不会造成无法释放的内存泄漏问题。 还有的问题 <img width="1011" alt="screenshot" src="https://user-images.githubusercontent.com/21049737/124604890-f8c7af80-de9d-11eb-9416-d18a8dfcd311.png"> 我用instrments 无法复现这张图,希望作者能帮我看看。
这个因为 [NSOperationQueue mainQueue] 并非单例,这个写法非常像单例,然后我运行下,发现不管在什么情况下 [NSOperationQueue mainQueue] 返回的地址都是相同的进一步证明了我的猜想,让后我下载了Gnustep源码,参考了下[NSOperationQueue mainQueue]和[NSNotificationCenter defaultCenter]写法一样都是单例,那么怎么确认是否有循环引用呢,






我参考了下NSNotificationCenter源码
这就证明了
然后参考addOperationWithBlock源码
所以[NSOperationQueue mainQueue]虽然是单例,但是不持有block,不会造成循环引用,传递完成就销毁了,不会造成无法释放的内存泄漏问题。
还有的问题

我用instrments 无法复现这张图,希望作者能帮我看看。