[Defy Android Development] YetAnotherForumUser:
TEST: procmem $(pidof mediaserver)|grep pvr

If that were to happen again it would be helpful if you could get some more info out of the offending process before killing it. Use [FONT="Monospace,Courier New"]procmem <pid>[/FONT] to get some basic memory mapping info ('where did that memory go'), [FONT="Monospace, Courier New"]strace -f <pid>[/FONT] to get an idea of what the process is doing at the moment - possibly combined with [FONT="Monospace, Comic Sans MS"]ls -l /proc/<pid>/fd[/FONT] to find out which file(s) the process is currently accessing. The latter can be helpful to find 'bad' files which mediaserver can trip on. The problem here is really a bug in mediaserver (which is easily confused by bad data) but a pragmatic solution in this case is just to get rid of offending files.

On my phone, running the JellyX kernel I compiled (and posted on this forum) everything is still running smoothly after 7 days+3 hours of uptime:

$ uptime
up time: 7 days, 03:00:43, idle time: 1 days, 05:29:04, sleep time: 4 days, 20:04:29
$ procrank
PID Vss Rss Pss Uss cmdline
31106 131344K 131300K 112480K 108652K com.android.browser
19681 52160K 52120K 38141K 34448K system_server
25491 32148K 32148K 31604K 31464K /system/bin/mediaserver
19662 31324K 31324K 23796K 17128K /system/bin/surfaceflinger
30341 30592K 30488K 17654K 16804K org.coolreader
19766 30508K 30472K 17495K 15000K com.android.systemui
19855 26296K 26256K 14594K 13928K com.android.phone
...
... (many lines deleted)
...
1293 40K 40K 36K 36K /system/bin/akmd2
------ ------ ------
393011K 360552K TOTAL

RAM: 488416K total, 27424K free, 2472K buffers, 55364K cached, 320K shmem, 10876K slab

Looking at mediaserver specifically it turns out to spend most of its memory on libpvr2d.so (information gleaned from procmem <pid>)

0K 0K 0K 0K 0K 0K 0K 0K /system/lib/libpvr2d.so
4K 4K 4K 4K 0K 0K 4K 0K /system/lib/libpvr2d.so
204K 204K 204K 204K 0K 0K 204K 0K /system/lib/libpvr2d.so
952K 952K 952K 952K 0K 0K 952K 0K /system/lib/libpvr2d.so
272K 272K 272K 272K 0K 0K 272K 0K /system/lib/libpvr2d.so
26308K 26308K 26308K 26308K 0K 0K 26308K 0K /system/lib/libpvr2d.so

After killing mediaserver and waiting for it to be restarted the newly reborn mediaserver does not link to that library yet. It does link to it when playing a video on youtube (using a few MB of dirty private memory) but the link is dropped (and the memory released) when the app is terminated. Opening the camera makes it link, using some 4 to 14 MB of dirty private memory (4 when taking a photo, 14 when previewing that photo from within the camera app) but again this link is dropped and the memory released on terminating the camera app. These results make me wonder if the mediaserver process on your phone used memory in the same spot: libpvr2d.so. Judging from what a simple search on the 'net produces, memory leaks are to be expected in this driver, just search for 'android powervr sgx driver memory leak' and you'll find some relevant bug reports (although that linked report might use the term 'leak' more to identify a privilege escalation leak than a straight-forward memory leak).

So... anyone with a bloated mediaserver (where 'bloated' would be 'PSS over 50 MB while not playing any video or sound) out there willing to give the following command a try and post the output here?

# procmem $(pidof mediaserver)|grep pvr

You'll need root to make [FONT="Monospace, Courier New"]procmem[/FONT] happy. If the output looks disappointing (hardly any memory used, no output because libpvr2s.so is not linked) just post the output of [FONT="Monospace, Courier New"]procmem $(pidof mediaserver)[/FONT] in its entirety.