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 ...
随机推荐
- HTML5 Canvas奇幻色彩Loading加载动画
转自 https://www.html5tricks.com/tag/loading%E5%8A%A8%E7%94%BB/
- 高度自适应的bug
今天在整理之前IFEde作业,发现有个简历的效果好像没实现.于是想把样式改成作业要求的那样. 作业要求是这样的: 右边栏昨晚高度是839px,我想把左边栏做成高度自适应的.但是没成功.现在我把这个问题 ...
- (38)zabbix中配置snmp监控
1.首先按照“snmp监控快速配置”文本文档在被监控的主机上安装.配置及启动snmp服务, 具体内容如下: 1).安装snmp yum install net-snmp* -y cp -a /etc/ ...
- 【转发】【composer】composer 命令行介绍
首页 入门 下载 安装包列表 中国镜像 命令行 你已经学会了如何使用命令行界面做一些事情.本章将向你介绍所有可用的命令. 为了从命令行获得帮助信息,请运行 composer 或者 composer l ...
- python面向对象(C3算法)(六)
1. 了解python2和python3类的区别 python2在2.3之前使用的是经典类, 2.3之后, 使用的是新式类 2. 经典类的MRO 树形结构的深度优先遍历 -> 树形结构遍历 cl ...
- (转)TDD的iOS开发初步以及Kiwi使用入门
本文转自“瞄神”博客 TDD的iOS开发初步以及Kiwi使用入门 测试驱动开发(Test Driven Development,以下简称TDD)是保证代码质量的不二法则,也是先进程序开发的共识.App ...
- 快速入门Numpy
教你十分钟学会使用numpy. 简单介绍一下numpy的话,这就是一个基于多维数组的python科学计算的核心库. 基本信息 # 一般用np作为numpy的缩写 import numpy as np ...
- EFCore CodeFirst模型迁移生成数据库备注(mysql)
重写Mysql下sql脚本生成器 using Framework.NetCore.Extensions; using Framework.NetCore.Models; using Microsoft ...
- 阿里云PolarDB及其共享存储PolarFS技术实现分析(下)
上篇介绍了PolarDB数据库及其后端共享存储PolarFS系统的基本架构和组成模块,是最基础的部分.本篇重点分析PolarFS的数据IO流程,元数据更新流程,以及PolarDB数据库节点如何适配Po ...
- TOJ 4804: 树网的核
这个是NOIP的提高组的题 4804: 树网的核 Time Limit(Common/Java):1000MS/3000MS Memory Limit:65536KByteTotal Sub ...