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.

  • 相关阅读:
    File
    多态
    方法重载
    Math
    instanceof
    强制类型转换
    泛型
    springboot热部署
    iOS bug处理
    iOS8-xcode6中添加pch全局引用文件
  • 原文地址:https://www.cnblogs.com/JiesonWu/p/2593488.html
Copyright © 2011-2022 走看看