Albert Renshaw
Albert Renshaw

Reputation: 17892

iOS drawInRect memory leak - ARC

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();

}

Upvotes: 1

Views: 1207

Answers (1)

Kurt Revis
Kurt Revis

Reputation: 27984

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

Upvotes: 6

Related Questions