Memory leak on reading images from document directory
<p>I am reading images from document directory in a loop.  </p>

<pre><code>for(iArrCount=0;iArrCount&lt;[arrImages count];iArrCount++)
    {
UIButton *btnImage = [UIButton buttonWithType:UIButtonTypeCustom];
            btnImage.frame = CGRectMake(xRow, yRow, width, height);
            [btnImage addTarget:self action:@selector(imageDetails:) forControlEvents:UIControlEventTouchUpInside];
            btnImage.tag = iCount;
            if(iCount&lt;[arrImages count])
            {


                NSString *workSpacePath=[[self applicationDocumentsDirectory] stringByAppendingPathComponent:[arrImages objectAtIndex:iCount]];
                [btnImage setBackgroundImage:[UIImage imageWithData:[NSData dataWithContentsOfFile:workSpacePath]] forState:UIControlStateNormal];
                [scrollImages addSubview:btnImage];
}
}  
</code></pre>

<p>On doing so, control goes to <code>didRecieveMemoryWarning</code> and application crashes.<br>
If I replace the image by a image from resource folder, application does not crashes.<br>
Why so?<br>
Thanks,<br>
Nitish</p>
