iOS drawInRect memory leak - ARC

1.2k views Asked by At

I've searched all over the internet and I have found alot of people with the same issue as me and no solution...

If I have something like an NSTimer and have it loop over and over and I stick this code in it for some reason I get massive memory leaks and the app crashes after about 100 or so loops.

But I have ARC enabled.

The memory issue is definitely win drawInRect according to instruments.

-(void)nstimerTick {

    UIGraphicsBeginImageContextWithOptions(testView.frame.size, NO, 0.0);

    [[testView image] drawInRect:testView.bounds];

    testView.image = UIGraphicsGetImageFromCurrentImageContext();

}
1

There are 1 answers

3
Kurt Revis On BEST ANSWER

You aren't calling UIGraphicsEndImageContext() at the end of your method. You should.