0

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)

RexOnRoids
  • 14,002
  • 33
  • 96
  • 136
  • You did not provide enough information to answer your question properly. The code you linked to seems sane, even it's total overkill for its purpose to read the color of one pixel. – Nikolai Ruhe Jul 17 '09 at 11:32
  • well, that's the code I used in my app. I know very little about the subject of graphics and buffers so I just did a copy and paste. The code allows me to get info about a given pixel but how to properly release/free the (buffer?) data after each touch? – RexOnRoids Jul 17 '09 at 11:41

1 Answers1

1

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.

Community
  • 1
  • 1
Nikolai Ruhe
  • 81,520
  • 17
  • 180
  • 200