Skip to content

函数返回一个对象时,会对对象 autorelease 么?为什么? #21

@tbfungeek

Description

@tbfungeek

会,其实AutoReleasePool的创建很大一部分原因就是为了解决函数返回对象的暂时管理的问题。我们知道在函数执行完毕,里面创建的变量将会被释放掉,但是返回值不一样,它需要被保留下来以便后续被持有被使用,但是在被其他持有之前它的内存管理交给谁?就是交给自动释放池来暂时管理。

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