FORUMS
Remove All Ads from XDA

[Solved] Media Scanner hogging CPU and battery

460 posts
Thanks Meter: 581
 
Post Reply Email Thread
Wanted to share my experience.

Symptoms:
  • Phone gets warm under camera
  • Battery drains fast (about 1-2% every minute)
  • Phone doesn't go into Deep Sleep
  • Process android.process.media uses about 20-25% CPU
  • Other third party applications may hog CPU; after killing/removing them android.process.media stays biggest CPU hog
  • Wiping data of Media Storage (under Settings -> Applications) may not help
  • Wiping all data (except sdcards), reflashing ROM etc. may not help

While media scanner is hogging CPU something like the following may be repeatedly logged in logcat
Code:
D/dalvikvm( 2237): GC_EXPLICIT freed 117K, 31% free 5599K/8008K, paused 2ms+3ms, total 39ms
D/dalvikvm( 2600): GC_CONCURRENT freed 342K, 54% free 3523K/7588K, paused 3ms+2ms, total 27ms
D/dalvikvm( 2237): GC_EXPLICIT freed 121K, 31% free 5600K/8008K, paused 2ms+3ms, total 44ms
D/dalvikvm( 2600): GC_CONCURRENT freed 347K, 53% free 3573K/7588K, paused 1ms+3ms, total 23ms
D/dalvikvm( 2237): GC_EXPLICIT freed 120K, 31% free 5598K/8008K, paused 2ms+2ms, total 38ms
D/dalvikvm( 2600): GC_CONCURRENT freed 337K, 53% free 3625K/7588K, paused 2ms+3ms, total 26ms
D/dalvikvm( 2600): GC_CONCURRENT freed 359K, 52% free 3666K/7588K, paused 3ms+5ms, total 58ms
D/dalvikvm( 2237): GC_EXPLICIT freed 117K, 31% free 5598K/8008K, paused 5ms+11ms, total 95ms
D/dalvikvm( 2600): GC_CONCURRENT freed 296K, 51% free 3762K/7588K, paused 3ms+2ms, total 33ms
Root cause:
  • A few ClockworkMod (CWM) recovery DUP backups (in my case 5)

Solution:
  • Delete ClockworkMod recovery DUP backups by connecting phone to PC in Mass Storage mode and deleting /clockworkmod/blobs from both sdcards (warning: you may want to backup /clockworkmod to PC before deleting these backups from phone)


DUP is default format for older versions of ClockworkMod recovery 6. DUP backup consists of all backed up files being copied to sdcard (without any form of archiving (except division into several hundred/thousand folders)), (theoretically) this format allows backing up only deltas. From the first moments I saw this format I knew it will have huge drawbacks (because it stresses filesystem, inappropriate for that kind of loads).
In versions of CWM recovery shipped with latest CM 10.1 nightlies default backup format is changed back to TAR (a few tar archives are written to sdcard). It may be possible to change backup format in backup and restore -> choose default backup format menu of CWM recovery.

Looks like when sdcard contains enough files (in my case about 12 000 from only 5 backups) Media Scanner (or may be Android system itself) runs into problems.
In my case first time I noticed the problem suddenly - last week my phone got warm and drained battery within 25 minutes. I charged phone, wiped data of Media Storage, it didn't help. Afterwards I connected phone to computer, checked both sdcards for errors (chkdsk reported that there were no filesystem errors), wiped data of Media Storage again and then problem mysteriously "disappeared" for a few days.
Yesterday I updated to latest CM 10.1 nightly, wiped cache and Dalvik Cache and on first boot the problem re-appeared. Reverting to previous ROM (older CM 10.1 nightly) didn't help. Backing up and wiping data also didn't help. Removing external sdcard also didn't help (because CWM DUP backups were on internal sdcard). Finally I thought that virtually the only remaining thing that can cause problems is CWM DUP backups, connected phone to PC (in Mass Storage mode) and deleted folder /clockworkmod/blobs from internal sdcard (warning: this will invalidate all DUP backups), again rebooted into recovery, wiped /cache and /data and problem was solved. Afterwards I restored from latest backup (which I made while already having this problem), just in case wiped data of Media Storage (under Settings -> Applications) once more and rebooted (the problem was solved).

CyanogenMod bug is here https://jira.cyanogenmod.org/browse/CYAN-745
Please vote for it, if you find this important!
The Following 19 Users Say Thank You to DavisNT For This Useful Post: [ View ]
 
 
1st April 2013, 02:53 PM |#2  
Senior Member
Thanks Meter: 3,226
 
More
Brilliant. Best thread I've seen on here in months. Kudos (Yes I both thanked you & rated the thread a 5).
The Following User Says Thank You to MistahBungle For This Useful Post: [ View ] Gift MistahBungle Ad-Free
1st April 2013, 03:17 PM |#3  
DavisNT's Avatar
OP Recognized Developer
Flag Riga
Thanks Meter: 581
 
Donate to Me
More
Quote:
Originally Posted by MistahBungle

Brilliant. Best thread I've seen on here in months. Kudos (Yes I both thanked you & rated the thread a 5).

Thank you for appreciating!
The Following User Says Thank You to DavisNT For This Useful Post: [ View ]
1st April 2013, 03:17 PM |#4  
immortalneo's Avatar
Senior Member
Flag Malappuram, Kerala
Thanks Meter: 1,876
 
More
Re: [Solved] Media Scanner hogging CPU and battery
A very useful read! Thank you for sharing! :thumbup::thumbup:

"To err is human, to forgive is divine"
Sent from my SGS II
Attached Thumbnails
Click image for larger version

Name:	uploadfromtaptalk1364825859447.jpg
Views:	301
Size:	54.5 KB
ID:	1850636  
1st April 2013, 03:40 PM |#5  
riro1612's Avatar
Senior Member
Germany
Thanks Meter: 18
 
More
AW: [Solved] Media Scanner hogging CPU and battery
I just use 2 apps called "media scanner" and "media scanner root". With the last I disable the media scanner and the other app activates the scanner for a specific time.

sent with my homing pigeon
13th May 2013, 12:26 PM |#6  
bobdoblo's Avatar
Senior Member
Thanks Meter: 21,165
 
More
Thanks for getting to the bottom of this issue:thumbup:

★NeatROM★ Mods ********************** Battery Guide
The Following 2 Users Say Thank You to bobdoblo For This Useful Post: [ View ] Gift bobdoblo Ad-Free
15th May 2013, 05:22 PM |#7  
gippy2's Avatar
Senior Member
Flag Stuck at XDA
Thanks Meter: 1,877
 
More
Thankyou so much..This worked a treat I had 20.000 files
15th May 2013, 11:46 PM |#8  
jon.walker1339's Avatar
Junior Member
Flag Belfast
Thanks Meter: 3
 
More
Very useful tidbit

Add a dab of lavender to milk, leave town with an orange and pretend your laughing at it.
19th May 2013, 07:23 PM |#9  
livefortoday's Avatar
Senior Member
Flag inside ur head
Thanks Meter: 103
 
More
I deleted the cwm/blob dir with
cwm -> backup & restore -> delete unused backup data.
the media scanner is fine now

now, I'm wondering if my backups are usable
or are they damaged, because I deleted the cwm/blob dir ?
20th May 2013, 08:46 AM |#10  
DavisNT's Avatar
OP Recognized Developer
Flag Riga
Thanks Meter: 581
 
Donate to Me
More
Quote:
Originally Posted by livefortoday

I deleted the cwm/blob dir with
cwm -> backup & restore -> delete unused backup data.
the media scanner is fine now

now, I'm wondering if my backups are usable
or are they damaged, because I deleted the cwm/blob dir ?

If entire /clockworkmod/blobs directory is cleaned/deleted, then all DUP backups are broken.
According to option's name it should only delete unreferenced files in this directory, thus leaving backups intact.
The Following User Says Thank You to DavisNT For This Useful Post: [ View ]
26th June 2013, 09:07 PM |#11  
Junior Member
Thanks Meter: 5
 
More
Thumbs up
Halleluiah. I was getting ready to revert back to the stock samsung rom due to battery issues. I deleted the "clockworkmod/backup" folder (after I backed it up on my computer), and the media scanner no longer hogs my cpu and battery.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes