onetamer
onetamer

Reputation: 73

iOS drawRect: is it possible to clear the Graphics Context?

I'm writing an iPad app and I have a custom view where I override drawRect to do a bunch of drawing. I have a timer calling the setNeedsLayout to refresh the graphics.

When I profile my application I see that the memory taken up by the application goes from 1.5MB to 600MB as the animation unfolds.

Also the previously drawn graphics don't go away, so I draw a white square over them before redrawing the new graphics.

I'm guessing some of the paths or shapes are remaining in the context. How can I clear it (remove everything from it)?

Upvotes: 1

Views: 876

Answers (1)

rob mayoff
rob mayoff

Reputation: 385600

It's not a matter of clearing the graphics context. You're probably leaking objects. Use the Leaks template in Instruments to help track them down. Or post your drawRect: code and we might be able to see some leaks.

Upvotes: 1

Related Questions