-4

In my iPad App,

I am using AQGridView.

This app is all about matching the cards to its categories.

In that I am deleting the cells.

If I am just opening the app for a few minutes it will not crashed.

But If I am playing the app for 3 to 4 minutes and deleting many cells it is getting crashes in the method.

Some memory leaks that I could not solve...

I have one array called imageMarray

I am doing shuffling on it.

In View Did Load.

 imageMArray=[NSMutableArray initWithArray:CategoryImages];
 imageMArray=[[self shuffleOnlyArray:imageMArray] retain];

In shuffleOnlyArray Method

-(NSMutableArray*)shuffleOnlyArray:(NSMutableArray*)sourceArray
{
    NSMutableArray *destArray1 = [[[NSMutableArray alloc] initWithCapacity: [sourceArray count]] autorelease];

    srandom( time(NULL));

    while ([sourceArray count] != 0)
    {
        NSUInteger index = (NSUInteger)(random() % [sourceArray count]);
        id item = [sourceArray objectAtIndex: index];
        [destArray1 addObject: item];
        [sourceArray removeObjectAtIndex:index];
    }

    [sourceArray release];
    sourceArray=nil;
    return destArray1;
}

And In shuffle Method I am writing

imageMArray=[[self shuffleOnlyArray:imageMArray] retain];

Where should I write release. So it does remove memory leak.

Arpit B Parekh
  • 1,932
  • 5
  • 36
  • 57

1 Answers1

2

If you think the issue is with reference counting, select 'Product > Analyze' to get Xcode to check all of your retain and releases and other issues.

Nathan Day
  • 5,981
  • 2
  • 24
  • 40