views:

72

answers:

1

Okay, I have an app that tells me what color of pixel I touched by reading the screen (like a screenshot) after each touch. To retrieve the pixels, I use a method similar to that appearing here. But it seems that after each touch, the image data is still being held on to (and not to mention saving hundreds of unwanted screenshots in my photo album by the way) and I start getting memory notifications shortly before the app finally crashes.... My app starts out at 3.5MB but after each touch this figure increases until it is at about 100MB, after which the app crashes.

QUESTION:
How do I free this data after each touch?
(Here is the link again for Source)

+1  A: 

The provided code frees all its buffers. The memory leak must be elsewhere.

If you want to use a more streamlined way of reading one pixel's color, you could consider the approach suggested in this answer. The idea is to use a very small buffer and draw the view with a transform that shifts the pixel into the range covered by the context.

Nikolai Ruhe