1. sanniv's Avatar
    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:@"img000%d.png",(start+i+1)] ofType:nil]]];


    [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.

    04-23-2009 01:30 AM
  2. sanniv's Avatar
    Hey Guys, Waiting for resolutions!!!!
    Please give ur suggestions...
    04-23-2009 07:14 AM
  3. M_of_IMAK's Avatar
    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:
    04-23-2009 09:56 AM
  4. sanniv's Avatar
    I got the solution for my problem
    05-05-2009 09:29 AM
  5. Tropical Pixels's Avatar
    Use NSMutableArray *myMutableArray=[NSMutableArray array]; and it will autorelease when you're finished using it.
    05-05-2009 11:44 AM