search

Home  >  Q&A  >  body text

objective-c - IOS main 函数中为何要包着 autoReleasePool ?

包着有何意义?不包似乎也没有出问题。

ringa_leeringa_lee2766 days ago375

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-04-24 16:02:32

    First of all, you need to know what is an automatic release pool in OC?
    Answer: The Autorelease pool is an automatic memory recycling mechanism of OC. Some temporary variables can be recycled and released uniformly through the automatic release pool. As long as any OC object calls the autorelease method, the object will be placed in the nearest autorelease pool (the release pool on the top of the stack).

    My personal guess is that the reason why the questioner thinks "there seems to be no problem if you don't include it" is that you are not involved in object orientation. In this case, it is recommended to learn the relevant knowledge of "memory management and automatic reference counting".

    reply
    0
  • Cancelreply