Question

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

}
Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top