mediaserverd process uses more memory each time a photo is taken
Using the activity monitor tool in Instruments, I've noticed that when using the SimplePhotoFilter example application the iPhone's "mediaserverd" process can grow in memory usage when taking still photos.
For example, in testing just now on an iPhone 4S, here's how much memory that process used as I took a few photos:
6.95 MB - before taking 1st photo 48.29 MB - after taking 1st photo 59.82 MB - after taking 2nd photo 71.58 MB - after taking 3rd photo
It seems to top out somewhere around 128 MB, and doesn't get any bigger.
Is this indication of a leak somewhere in GPUImage? or is this expected behavior for that mediaserverd process (it clears out its memory usage as needed)?
Once you close SimplePhotoFilter, mediaserverd goes back down to its original 6-7 MB memory usage.
I notice similar behavior with the mediaserverd process when using the Instagram application (which also processes images using Open GL), so this is probably a non-issue and I'm closing it...
... though, the way Instagram is structured, where you're usually posting a photo right after taking it - rather than taking successive photos one after the other - the camera interface is closed often which clears out the memory used by mediaserverd.
If it was a leak, I'd expect it to keep growing. I did find and fix a different leak in the latest code, but it wasn't this.
Near as I can tell, mediaserverd handles media compression and decompression, so at first I thought this was due to the JPEG compression saving the photo. However, when I commented that part of the code out, mediaserverd still increased at the same rate as we see here.
It's possible that this contains the iOS 5.0 texture cache mechanism, which might cause it to increase in size with creation of the photo-sized cached textures. I free these properly, and flush the cache regularly, so there shouldn't be buildup. Maybe the cache just increases as much as memory allows, then only starts purging itself when it gets too large.
I don't once get a memory warning even after taking dozens of photos, so this might just be a safe caching mechanism. I'll keep investigating, though.
Thanks for looking into it, and for the explanation. :)