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 ...
随机推荐
- html节点类型
<li> nodeType:节点类型: <br> 1--->Element节点: <br> 3--->Text节点: <br> 8---&g ...
- UVa 291 The House Of Santa Claus——回溯dfs
题意:从左下方的1开始,一笔画出圣诞老人的房子. #include <iostream> #include <cstring> using namespace std; ][] ...
- (14)zabbix Simple checks基本检测
1. 开始 Simple checks通常用来检查远程未安装代理或者客户端的服务 使用simple checks,被监控客户端无需安装zabbix agent客户端,zabbix server直接使用 ...
- Elementary OS上eclipse卡死问题
解决: 1.可以用 sudo ./eclipse -vm /home/username/jdk_path/bin/java 启动但是启动后仍有显示问题. 2. 修改 eclipse.ini 在 -- ...
- vuex其实超简单,只需3步
前言 之前几个项目中,都多多少少碰到一些组件之间需要通信的地方,而因为种种原因,event bus 的成本反而比vuex还高, 所以技术选型上选用了 vuex, 但是不知道为什么,团队里的一些新人一听 ...
- Django之学员管理一
Django之学员管理一 建表结构: #班级表class: id title 1 五年一班 2 五年二班 3 五年三班 4 五年四班 #学生表student: id name 班级ID(FK外键) 1 ...
- Linux服务器硬件设备信息查看
一.cpu信息 cpu信息存储在/proc文件系统的cpuinfo(/proc/cpuinfo)文件里,可以直接查看这个文件以获得cpu信息,所列字段解释如下: processor : 核心编号,如: ...
- Poj 1041--欧拉回路
Description Little Johnny has got a new car. He decided to drive around the town to visit his friend ...
- jq:mouseover和mouseout多次触发解决办法
区别: mouseover与mouseenter 不论鼠标指针穿过被选元素或其子元素,都会触发 mouseover 事件. 只有在鼠标指针穿过被选元素时,才会触发 mouseenter 事件. mou ...
- 九度oj 题目1262:Sequence Construction puzzles(I)_构造全递增序列
题目描述: 给定一个整数序列,请问如何去掉最少的元素使得原序列变成一个全递增的序列. 输入: 输入的第一行包括一个整数N(1<=N<=10000). 接下来的一行是N个满足题目描述条件的整 ...