How to resolve 'Potential Leak' issue
|
I am using the 'analyze' tool in xcode to check for potential leakages in my app. I am getting the following warning as a result.
How do I resolve the potential leak shown above? "self.answerArray" is just an array I declared in my header file
|
解决 :
You've called mutableCopy on the array (which returns a new array with a retain count of +1 - You own it), and you assign it to a property (which I assume is a strong/retain property) and you're not releasing it. You're leaking the memory.
You should release tempArray after assigning it to the property - and ensure the property is released in your class' dealloc method.
这个项目中遇到类似的问题
if (self.newsList) {
for (int count = 0; count < [ self.newsList count]; count ++) {
self.currentRecord = [ self.newsList objectAtIndex:count];
if ([[[self.currentRecord .personVOList objectForKey:@"pk"] stringValue] isEqualToString:((KidsAppDelegate*)[[UIApplication sharedApplication]delegate]).currentKidPK]) {
NSMutableArray * localArray = [((KidsAppDelegate*)[[UIApplication sharedApplication]delegate]).currentKidNewsList mutableCopy];
self.currentNewsList = localArray; //或者书写为
self.currentNewsList = [((KidsAppDelegate*)[[UIApplication sharedApplication]delegate]).currentKidNewsList mutableCopy];
都会有以上的问题存在
break;
}
}
}
修改方式:
if (self.newsList) {
for (int count = 0; count < [ self.newsList count]; count ++) {
self.currentRecord = [ self.newsList objectAtIndex:count];
if ([[[self.currentRecord .personVOList objectForKey:@"pk"]
stringValue] isEqualToString:((KidsAppDelegate*)[[UIApplication
sharedApplication]delegate]).currentKidPK]) {
NSMutableArray * localArray = [((KidsAppDelegate*)[[UIApplication sharedApplication]delegate]).currentKidNewsList mutableCopy];
self.currentNewsList = localArray; //或者书写为
[localArray release];或者
NSMutableArray * localArray = [[((KidsAppDelegate*)[[UIApplication sharedApplication]delegate]).currentKidNewsList mutableCopy] autorelease];
break;
}
}
}
How to resolve 'Potential Leak' issue的更多相关文章
- A memory leak issue with WPF Command Binding
Background In our application, we have a screen which hosts several tabs. In each tab, it contains a ...
- iOS 错误 之 Potential leak of an object stored into 'cs'
存储到 “cs”的对象存在潜在的泄露
- Resolve Missing artifact Issue in maven
https://jingyan.baidu.com/article/d621e8da0a5b192864913f79.html
- RocketMQ 源码学习笔记————Producer 是怎么将消息发送至 Broker 的?
目录 RocketMQ 源码学习笔记----Producer 是怎么将消息发送至 Broker 的? 前言 项目结构 rocketmq-client 模块 DefaultMQProducerTest ...
- RocketMQ 源码学习笔记 Producer 是怎么将消息发送至 Broker 的?
目录 RocketMQ 源码学习笔记 Producer 是怎么将消息发送至 Broker 的? 前言 项目结构 rocketmq-client 模块 DefaultMQProducerTest Roc ...
- RocketMQ(二):producer客户端实践
MQ解耦了生产者和消费者,前提是有一个稳定强大的消息服务,我们只管与之通信即可. 所以,和MqServer通信是什么样的?难否? 0. 发送端demo /** * This class demonst ...
- SilverLight - Memory Leak
There is a memory leak issue in current silverlight project. It occurs in the search function: the m ...
- Use UMDH to identify memory leak problem
We sometimes got memory leak problem, and we need to find the leaked memory, Here is a usful tool fr ...
- Android Lint Checks
Android Lint Checks Here are the current list of checks that lint performs as of Android Studio 2.3 ...
随机推荐
- OpenWrt 路由器如何让 lan 口主机获得 ipv6 网络访问 -- 知乎
本文转自知乎: OpenWrt 路由器如何让 lan 口主机获得 ipv6 网络访问? - mistforest的回答 - 知乎https://www.zhihu.com/question/29667 ...
- mysql:破解MySQL密码的一种方法
1, 修改mysql配置文件/etc/my.cnf 12 [mysqld]skip_grant_tables 2, 重启mysql后直接用root用户登录(不用输入密码) 1 $ mysql -uro ...
- python--管道, 事件, 信号量, 进程池
一 . 管道 (了解) from multiprocessing import Process, Pipe def f1(conn): # 管道的recv 里面不用写数字 from_main_proc ...
- 9-Python基础知识-day1
Python基础知识-day1 Python 2 和Python 3 的区别: Python2 源码不标准,混乱,重复代码多:#-*-encoding:utf8 -*- 解决python2显示中文的问 ...
- HUB、Switch、Router在OSI模型层次信息
序 (HUB)集线器工作在局域网(LAN)环境,像网卡一样,应用于OSI参考模型第一层,因此又被称为物理层设备. Switch交换机工作在OSI第2层数据链路层 Router路由器工作在OSI第3层网 ...
- js的setInterval和setTimeout的那些浅坑
setInterval和setTimeout的区别简单提一下 setInterval() :按照指定的周期(以毫秒计)来调用函数或计算表达式.方法会不停地调用函数,直到 clearInterval() ...
- 转载: LINK : fatal error LNK1104: 无法打开文件“mfc71.lib”的原因又一例
转载地址:http://blog.csdn.net/mxclxp/article/details/8196142 LINK : fatal error LNK1104: 无法打开文件“mfc71.li ...
- Spring-IOC源码解读2.1-BeanDefinition的Resource定位
Spring通过ResourceLoader来处理得到的Resource.在前面我们知道容器初始化是以refresh()方法为入口的,内部的实现首先准备上下文,然后通过obtainFreshBeanF ...
- 洛谷 [P2964] 硬币的游戏
博弈论+dp 依旧是博弈论的壳子,但问的是最大值,所以要dp 设 dp[i][j] 表示该取 i 号硬币,上一次取了 j 个的先手能取的最大值, 因为每次从小到大枚举复杂度太高,所以我们要从 dp[i ...
- 标准C程序设计七---17
Linux应用 编程深入 语言编程 标准C程序设计七---经典C11程序设计 以下内容为阅读: <标准C程序设计>(第7版) 作者 ...

