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 ...
随机推荐
- angular-file-upload 在IE下使用的坑
如果在控件配置里面设置了queueLimit属性为1,就是队列文件个数为1,并且在<input>标签设置里multiple属性. 在IE浏览器上传附件的时候,浏览器会报错“SCRIPT50 ...
- Linux文件权限与文件夹权限实践
文件权限在基础中有介绍,不在重复 一.文件夹权限: 示例: 解释说明: r --read 既ls w --write 既创建新的目录或者文件 x --execute 既cd 现在有4个用户分属 ...
- HUD--2553 N皇后问题
Problem Description 在N*N的方格棋盘放置了N个皇后,使得它们不相互攻击(即任意2个皇后不允许处在同一排,同一列,也不允许处在与棋盘边框成45角的斜线上.你的任务是,对于给定的N, ...
- 【02】xmind如何修改默认线条设置
[02]xmind如何修改不同主题的默认线条设置 魔芋:每次都是曲线.更喜欢为直线.因为曲线的路线是不确定的,看起来就显示很凌乱. 用everything搜索defaultStyles.xml ...
- kali-set
Set 简介 开源的社会工程学利用套件,通常结合metasploit(部分)来使用 更改 /etc/setoolkit下的配置文件 set_config BLEEDING_EDGE="Fal ...
- x86保护模式 任务状态段和控制门
x86保护模式 任务状态段和控制门 每个任务都有一个任务状态段TSS 用于保存任务的有关信息 在任务内权变和任务切换时 需要用到这些信息 任务内权变的转移和任务切换 一 ...
- 初识LiveScript
The LiveScript Book 邂逅 LiveScript 就像很多现代化的语言一样,LiveScript 使用缩进来表示语句块,使用换行取代分号来表示一个语句的结束 (如果你想要一行 ...
- php(ajax)异步刷新(转)
第一种方法,ajax实现:当然,ajax使用起来确实很简单就可以实现,但是里面的很多知识还是比较有点深的.我之前做页面时间自动刷新的功能就是用的ajax.完整代码是:1.getTime.php: 复制 ...
- hlg 1580 tell me the length
智力题,观察上一行,有几个数字. 比如,S[1]=1; S[2]=11; S[3]=21; S[4]=1211; 这样就可以观察出来,序列一是1个1 ---> S[2] = 11 ; 序列二是 ...
- poj2431 Expedition优先队列
Description A group of cows grabbed a truck and ventured on an expedition deep into the jungle. Bein ...

