zoukankan      html  css  js  c++  java
  • Using Autorelease Pools

    There are, however, three occasions when you might use your own autorelease pools:

    1.  If you are writing a program that is not based on a UI framework, such as a command-line tool.

    2. If you write a loop that creats many temporary objects.

    3.  you spawn a secondary thread.  

    (2) Autorelease Pools and Threads

    Each thread in a Cocoa application maintains its own stack of NSAutoreleasePool objects. When a thread terminates, it automatically releases all of the autorelease pools associated with itself.

     

    (3) ownership

     * If you create an object, you own it.

     * If you get an object from somewhere else, you do not own it. if you want to prevent it being disposed of, you must add yourself as an owner.

     * If you are an owner of an object, you must relinquish ownership when you have finished using it.

  • 相关阅读:
    第四次
    jsp
    2021.3.4
    第八次作业
    第七次作业
    第六周作业
    第五周作业
    第四周
    第四次jsp作业
    第二次作业
  • 原文地址:https://www.cnblogs.com/JiesonWu/p/2593488.html
Copyright © 2011-2022 走看看