应用程序终止时,系统是否释放我的对象? [英] Does system release my objects when the application is terminated?

查看:95
本文介绍了应用程序终止时,系统是否释放我的对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我总是想知道有时候,当我运行我的应用程序时,会创建一个应用程序池,并且我的应用程序会加载到该应用程序池中,而当我按下主页"按钮时,我的应用程序会终止,即,我的应用程序所在的池会终止因此,在这种情况下,如果我不释放这些对象,这些对象会发生什么情况,我认为它们也会被终止,但是苹果公​​司不建议使用这种方法,因为这是出于什么原因.任何绅士都可以给我一个可靠的答案,因为这几天确实困扰了我很多.

i always wonder sometimes that when i run my app an app pool is created and my app gets loaded inside the app pool and when i hit the home button my app is terminated i.e. the pool in which my app was residing will be terminated so in this case what will happen to those objects if i do not release such objects i think they will be terminated too but this methodology is not recommended by apple god knows for what reason. Can any gentleman provide me a solid answer for this question because it has really bugged me a lot these days..

感谢&问候

推荐答案

每当您的应用程序终止时,已分配的内存就会返回给系统.如果这就是应用程序池"的意思,则自动释放池在这种情况下不起作用.此时仍在内存中的对象将不会被释放(在某种意义上,系统将为您调用dealloc),相应的内存仅被标记为空闲.

Whenever your application is terminated the memory it had allocated is returned to the system. Autorelease pools don't play any role in this case, if that's what you mean by "application pool". The objects that are still in memory at that moment will not be deallocated (in the sense that system would call dealloc for you), the corresponding memory is simply marked as free.

这篇关于应用程序终止时,系统是否释放我的对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆