I noticed that my Motorola Droid, running rooted 2.2 Froyo, has been acting sluggish sometimes. I fired up the terminal emulator, and ran top, and noticed that /system/bin/mediaserver is using around 90% of my CPU.

What does this program do? Is it safe to kill it? How can I prevent it from slowing down my phone in the future?

Some quick Googling has turned up other people with the same problem, but not really any answers.

5 Answers
5

The media server is responsible for indexing the images, videos and music files on the device. It then is queried by programs like the media gallery or the music player for filtered lists of certain media types.

I think that it would be restarted pretty fast after killing. I would assume that somehow there are many write options on the sd card and the media server will constantly reindex your mass storage. But I don't know a solution for that.

Okay, thanks. I noticed this behavior after I moved a bunch of my apps out of internal memory, and onto the SD card, so I suppose all of those writes explains why mediaserver went a little crazy.
– pkaedingAug 9 '10 at 20:22

What is meant by "indexing images, videos and music"? Does it try to do image recognition or what?
– DimsSep 12 '18 at 12:47

As Janusz explained, this program scans and indexes media files on the internal and removable storage. Sometimes the media scanner using a lot of CPU can be a result of it trying to scan one or more corrupted files. This is usually a symptom of your SD card starting to fail. Try scanning your SD card's filesystem for errors on a proper computer (e.g. using fsck on a GNU/Linux system, or Scandisk on Windows). If any errors are detected and fixed, put the SD card back in your phone and see if the problem goes away.

Simplest solution is, if you can identify where in memory card you have junk image files, then just place a .nomedia file. Which avoids scanning that perticular folder for indexing media files (Note: It will also not appear in gallery).

In my case I did that to Whatsapp images folder, which had hell lot of images but I dont want it to be appearing in my gallery. So I thought it would work for me.

Same way you find out such content and then try to clean up unwanted stuff, also look for any corrupted media files also and remove them.

In my particular case the mediaserver process was spinning with scanning the temporary/junk files cached by the browser and other programs. As long as I started running a junk file cleanup program at least daily I no longer have this problem.

as you may already know it's a binary file it is used by android to scan the phone's storage for media files (images , sounds and videos ) android usually run it on boot and on media storage changes (like sending new files from pc via mtp ,removing and inserting SD card or usb OTG storage devices ,downloading new media files ect .. )

why is it pegging the CPU?

Now that can be for multiple reasons I will list some of them

SD card ,media Storage ,USB devices corrupted file system : in some cases the storage gets corrupted which make the mediaserver use more resources to scan and in some cases the process gets stuck with an i/o error that it can't handle.

some third party applications may abuse the use of mediaserver in so many ways ,like forcing the android system to rescan explicitly or passively ,explicitly is when the application developer made it so in this case only removing that app or contacting the developer may solve the problem but when the app passively make the media server run like when an app writes junk or cache media files (images ,sounds ,video ) in directories that are not exclude by the media scanner which forces the android system to rescan more often to prevent this you need to find the folder where this app puts junk files and exclude it from the media scanner by creating an empty file named .nomedia inside that folder in fact you can use this methode to exclude any folder from being scanned my the media scanner.

the point is ,the problem is not in the mediaserver binary it self because this binary can be used by any third party app which makes it difficult to determine who is abusing it's use.