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.

  • 相关阅读:
    elf和内存分布
    平衡二叉树
    sdio驱动
    wifi
    阻塞赋值与非阻塞赋值
    线性失真与非线性失真
    数字前端,后端介绍
    总线
    并行全比较排序算法&并对角标排序
    verilog memory
  • 原文地址:https://www.cnblogs.com/JiesonWu/p/2593488.html
Copyright © 2011-2022 走看看