Skip to content

第39题的一些疑问 #138

@jhz-libowen

Description

@jhz-libowen

这个因为 [NSOperationQueue mainQueue] 并非单例,这个写法非常像单例,然后我运行下,发现不管在什么情况下 [NSOperationQueue mainQueue] 返回的地址都是相同的进一步证明了我的猜想,让后我下载了Gnustep源码,参考了下[NSOperationQueue mainQueue]和[NSNotificationCenter defaultCenter]写法一样都是单例,那么怎么确认是否有循环引用呢,
我参考了下NSNotificationCenter源码
screenshot
screenshot
screenshot
这就证明了
screenshot
然后参考addOperationWithBlock源码
screenshot
screenshot
所以[NSOperationQueue mainQueue]虽然是单例,但是不持有block,不会造成循环引用,传递完成就销毁了,不会造成无法释放的内存泄漏问题。

还有的问题
screenshot
我用instrments 无法复现这张图,希望作者能帮我看看。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions