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 ...
随机推荐
- noip_最后一遍_3-数据结构
noip基础数据结构太多了又太捞了 所以也就那么几个了 单调队列滑动窗口 #include<bits/stdc++.h> using namespace std; #define maxn ...
- [LUOGU] P3128 [USACO15DEC]最大流Max Flow
题意:一棵树,多次给指定链上的节点加1,问最大节点权值 n个点,n-1条边很容易惯性想成一条链,幸好有样例.. 简单的树剖即可!(划去) 正常思路是树上差分,毕竟它就询问一次.. #include&l ...
- (6)zabbix主机与组配置
1. 创建主机方法 1.1 新建主机configuration(配置)->Hosts(主机)->Create host(创建主机) 见前面的博文 1.2 克隆/完全克隆主机 2. 主机参数 ...
- linux运维中常用的指令
一.终端中常用的快捷键 man界面中的快捷键: ?keyword 向上搜索关键词keyword,n向下搜索,N继续向上搜索 /keyword 向下搜索关键词keyw ...
- centos7.2安装redis与配置(史上最全)
学习了php已经快三年了,一直是在盲目的忙,也没整理下笔记,今天整理一下 分享下安装redis的方法 #首先去redis官网去下载 http://www.redis.cn/download.htm ...
- 1、初学探讨PYTHON的itchat和wxpy两库
最近好奇学习了python,觉得简单明了,但是最头疼的就是调整空格和调试吧,的确调试不如C#使用visual studio 方便,都是使用print()来调试.也许因为我是菜鸟,如果大家还有更好的方法 ...
- django(django项目创建,数据库迁移)
Django项目的创建与介绍 安装:pip3 install django==1.11 查看版本号:django-admin --version 新建项目: 1.切到目标目录 2.django-adm ...
- (转))iOS App上架AppStore 会遇到的坑
iOS App上架AppStore 会遇到的坑 前言:非原创 文章摘自:http://zhuanlan.zhihu.com/100000PM/20010725 相信大家一定非常「深恶痛疾」AppS ...
- DFS:POJ3620-Avoid The Lakes(求最基本的联通块)
Avoid The Lakes Time Limit: 1000MS Memory Limit: 65536K Description Farmer John's farm was flooded i ...
- python基础学习笔记——方法返回值
字符串中(需要有变量接收) 判断是不是阿拉伯数字,返回的是布尔值 1 2 3 4 name = 'alexdasx' new_name = name.isdigit() print(new_name) ...