NSMutableArray release Problem

sanniv

New member
Apr 23, 2009
4
0
0
Visit site
Hello Guys,

I am stuck in crashes. I m doing following thing in a function

NSMutableArray *myMutableArray=[[NSMutableArray alloc] initWithCapacity:0]];

for (int i=0;i<10;i++)
[myMutableArray addObject:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:mad:"img000%d.png",(start+i+1)] ofType:nil]]];

self.myImageView.animationImages=myMutableArray;

[myMutableArray removeAllObjects];

//[myMutableArray release];

I have around 50 images and I load only 10 at a time for a purpose, I am controlling this my "start" variable which contains the initial point. And I want to free previous loaded images while loading new ones.

But when I uncomment the release method My program crashes..
And if I do not release My memory is not being freed, as I checked in Instruments, although there is not leak in Leaks but still object allocation goes on and on with overall system memory of 100 MB. And because of this I get Low Memory Warning in program when I test in the device. I don't know what is the problem here. Please let me know if anyone has resolution.

Thanks in advance.

Regards,
Sanniv.
 

M_of_IMAK

Member
Apr 23, 2009
10
0
0
www.IMAKcreations.com
I'm not sure the error is in the code snippet that you show. Could you put this code snippet in a new project and see if you get the same crash behavior when you do the release? For purposes of this test, don't have the line:
self.myImageView.animationImages=myMutableArray;
 

Trending Posts

Members online

Forum statistics

Threads
259,610
Messages
1,763,750
Members
441,187
Latest member
97Shenae59