简体   繁体   English

在IOS中注销时如何释放保留的对象或应用程序的内存

[英]How to release the retained objects or memory of app while logging out in IOS

I wanted to know that how we gonna release all the memory retained by the view controller in app while logging out. 我想知道注销时如何释放视图控制器在应用程序中保留的所有内存。

I checked my app using instrument that the allocations were not released while logging out though i am on my logging screen. 我使用仪器检查了我的应用程序,虽然我在登录屏幕上,但注销时未释放分配。

as after using the app for a while the allocation shown by instruments goes to 10Mb but after logging out I am on login screen but the allocation are still the same ie 10MB. 在使用该应用程序一段时间后,仪器显示的分配达到10Mb,但注销后我在登录屏幕上,但分配仍然相同,即10MB。

I dont know how to modify that logout function so that i can clear the data retained by the other views.. 我不知道如何修改该注销功能,以便我可以清除其他视图保留的数据。

What you seem to want to do is to create your own garbage collector. 您似乎想要做的是创建自己的垃圾收集器。

Change your mindset. 改变心态。

What you need to be aiming for are: objects which release any memory they are retaining in their "dealloc" method. 您需要针对的是:释放其“ dealloc”方法中保留的任何内存的对象。

The important thing is to release every object you alloc, copy, mutableCopy, new or retain. 重要的是释放您分配,复制,mutableCopy,新建或保留的每个对象。 Also, use the Zombie tool in simulator to check for zombies (in addition to the Leaks and Allocations tools). 另外,使用模拟器中的“僵尸”工具检查僵尸(除了“泄漏和分配”工具之外)。

you say: "clear the data retained by the other views". 您说:“清除其他视图保留的数据”。 But "the other views" should be clearing the data they retain. 但是“其他视图”应该清除它们保留的数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM