简体   繁体   中英

how can i check object count and release that object according to it's retain count?

有时我释放特定对象,但仍然显示内存泄漏,因此我应该给出哪种条件才能解决与内存有关的问题?该特定对象在Application Delegate类中分配,并且可以从许多View Controller访问该对象我删除内存泄漏?

The golden rule for memory management by reference counting is to concentrate on the scope, where the object is used. You retain it as long as you work with it and release it afterwards.

The whole rationale behind reference counting is to never issue more releases than retains for a certain scope. If you expect an object to get deallocated at a certain point and it doesn't, look for the root cause of the problem.

Could it be, that you erroneously assume a certain object to be autoreleased?

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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