malloc

开场白:chm确实是个好东西,比pdf好多了,可以调整字体大小还可以另外打开图片呢

话说我下了一本Cocoa Programming 3rd Edition之后,看了下目录,发现有一章叫
Memory Management

然后从中我得知两个重要信息,Mac应用程序是这样管理内存的 :

10.5之前,用很传统的方法,就是给每个对象分一个属性,表明多少其他对象在用它。
这样很直观,但是容易产生引用循环
就是两个其实没用了的对象互相引用对方结果一直占住内存

10.5的cocoa新增加一个方法,启用这个方法就可以自动整理内存鸟
( NSGarbageCollector)
但是很显然 吃资源啊~
因此做什么音频视频这频那频的软件就别用这个了
要不然你就知道为什么有时候看视频时会卡卡的原因了

而且我也算是知道为什么有些软件标明是哪个哪个版本的系统以上才能用的了

另附原文如下:
  1. The old solution uses retain counts: Every object has a retain count, which should represent the number of other objects that have pointers to it. If the color is the favorite of two people, the retain count of that color should be 2. When it goes to zero, the object is deallocated.

  2. The new solution, introduced in 10.5, is a garbage collector, which babysits the entire object graph, looking for objects that can't be reached from the variables that are in scope. The unreachable objects are automatically deallocated.



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值