释放问题 [英] releasing problems

查看:80
本文介绍了释放问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道我的问题不是唯一的,但是我已经分析了许多源代码,但没有一个能很好地工作. 我正在创建一个包含100个图像的数组,这些图像将用于UIImageView动画,并且在完成动画之后,我想释放内存.

Yes, I know that my problem is not the unique, but I have analysed many source codes but nothing works well. I am creating an array of 100 images which will be used for UIImageView animation and after finishing animation I want to free the memory.

.h

IBOutlet UIImageView * 1法师;

IBOutlet UIImageView* 1mage;

.m

NSMutableArray * 1mageArray = [[[NSMutableArray alloc] initWithCapacity:99];

NSMutableArray* 1mageArray = [[NSMutableArray alloc]initWithCapacity:99];

for(int i = 1; i< = 100; i ++){ [1mageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"1mage _%.4d.png",i]]]]; }

for (int i=1; i<=100; i++) { [1mageArray addObject:[UIImage imageNamed:[NSString stringWithFormat:@"1mage_%.4d.png",i]]]; }

1mage.animationImages = 1mageArray;

1mage.animationImages = 1mageArray;

1mage.animationDuration = 8.0;

1mage.animationDuration = 8.0;

1mage.animationRepeatCount = 0;

1mage.animationRepeatCount = 0;

[1mage startAnimating];

[1mage startAnimating];

[1mageArray版本];

[1mageArray release];

我已经阅读了《内存管理指南》,似乎一切正常,但是调试器与我不同意,并且播放动画后我仍然有60 MB的空间.

I have read Memory Management Guide, and seems, like I am doing everything okay, but debugger does not agree with me, and after playing the animation I still have 60 MB used.

提前谢谢!

copy/paste,我用1代替了长文本,从而缩短了变量的长度.

copy/paste , and I shorted variables by replacing the long text with 1. do not pay attention on this!

推荐答案

当您设置animationImages时,您的图像将保留数据.毕竟,需要那些图像,不是吗?

Your image will retain the data when you you set the animationImages. After all, it needs those images, doesn't it?

如果您释放它或将其animationImages属性设置为nil,它们可能会被释放...

If you release it or set its animationImages property to nil, they might be released...

这篇关于释放问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆