Remove All Ads from XDA

[Xposed] [5.0.x] Fix Lollipop Memory Leak

5,022 posts
Thanks Meter: 34,981
By tonyp, Inactive Recognized Developer on 27th March 2015, 01:34 AM
Post Reply Email Thread
Fix Lollipop Memory Leak
(for Android 5.0.x only)

Download @ Google Play

A module to get rid of the infamous Android 5.0.x ColorFade memory leak bug.

As Xposed still didn't receive an official update for Android 5.1 I hope this can make the wait a little bit easier.
Same goes for those poor fellas who didn't receive a 5.1 update, yet.
This particular Memory Leak got fixed by Google in Android 5.1, so there's no use of installing this module on Android versions other than 5.0, 5.0.1 and 5.0.2 (in fact it will detect 5.1 and disable itself).

The leak apparently happens due to the Screen Off animation not releasing it's ressources.
I followed the official Android 5.1 patch to fix this issue with Xposed.

This module is intended to be used with AOSP and GPE ROMs, but should work on vendor ROMs (HTC, LG etc.) as well.
Based on feedback from this thread it has positive effects on Motorola and LG devices, too.
There's no need to use it on up-to-date CM12 ROMs, they already applied the patch in question with this commit.
Same thing for Sony Stock ROMs, the fix is already included, see here for more info.

A memory leak in the SystemUI exacerbates over time, so it gets worse the longer your device is in use and hasn't been restarted.
More and more memory gets allocated but not released thus the available memory for other apps to claim is lessened gradually over time.
Additionaly keep in mind that there are several memory leaks in Lollipop (although this is probably the worst one).
Google fixed the ColorFade Memory leak with some others in Android 5.1 but still missed at least one major leak.
While memory leaks are quite common and probably happen to some extent in pretty much all software releases it seems as if Google has been quite sloppy in that field lately.

The module is open source, so you can validate the code and possibly send me pull requests.

Update: So far the feedback for this module has been nothing but positive.
It seems like this module truly benefits most devices with Android 5.0

Source Code:
Last but not least an obligatory huge thanks to @rovo89 for his amazing Xposed framework!

If you like this module don't forget to press thanks, rate this thread with 5 stars, consider a donation etc. etc.

The Following 270 Users Say Thank You to tonyp For This Useful Post: [ View ] Gift tonyp Ad-Free
27th March 2015, 01:34 AM |#2  
tonyp's Avatar
OP Inactive Recognized Developer
Thanks Meter: 34,981
Donate to Me
Mini FAQ:

What is a Memory Leak? (reddit : eli5):

The computer has a certain amount of memory, obviously. Each piece of memory belongs to just one specific program at one time, or else it is free. Each application requests memory from the OS whenever it needs more, and gives it back to the OS again once it is done with it. So a memory leak is when a program requests memory but forgets to give it back. If this continues to happen over and over again, then as long as the program keeps running, it will own more and more of the computer's memory until eventually there is no memory left for other programs.

What this module doesn't do:
  • It won't magically make your device run faster
  • It won't do anything on recent CM12 ROMs as they already fixed it
  • It won't fix other memory leaks than the ColorFade one (which is the most sincere in Android 5.0, though)
  • It won't work on Samsung Stock ROMs as Xposed still isn't compatible
  • It won't do anything on Android 5.1 ROMs as Google already fixed it
    (yes, I know they missed/introduced at least one other major leak, but as they did not make the patch public no one can easily fix this in a custom ROMs or via Xposed)
  • It won't combine random funny cat videos with awesome music for your proc(r)astination needs.
    You might want to use the Procatinator for that.

What this module does do:
  • Fix the ColorFade Memory Leak reported to Google here and fixed in Android 5.1 here.
  • Thus it should ensure that more free memory is available for your system and apps in the long run

Further information:
  • Android Police: Notorious Lollipop Memory Leak That Caused App Crashes Finally Fixed After Over 1750 Stars In Issue Tracker
  • Reddit: Biggest lollipop issue now marked "future release" - Issue 79729
  • AOSP issue tracker: Issue 79729: Memory Leak on Lollipop crashing Apps

A more technical explanation on the cause of thise particular issue (Stackoverflow):

Yes -- in fact it is highly desireable to detach and delete your shader objects as soon as possible. That way the driver can free up all the memory it is using to hold a copy of the shader source and unlinked object code, which can be quite substantial. Measurements I have done indicate that NOT deleting the shader objects increases the incremental memory use per shader by 5-10x

- Don't require a reboot for preference changes
- Reference the Xposed framework rather than compiling it (reduces the app size from 65KB to 31KB)
- Restrict PlayStore listing to Android 5.0 devices
- Merged Korean translations by SDKoongchi

- Minor code improvements (thanks @kmark!)
- Added settings interface
- Published at Google Play

- initial release
The Following 16 Users Say Thank You to tonyp For This Useful Post: [ View ] Gift tonyp Ad-Free
27th March 2015, 01:38 AM |#3  
ih8legal's Avatar
Senior Member
Thanks Meter: 97
Thumbs up
Interesting. Going to test on my N5 pronto. If it works. You are a godsend man. Can't be without xposed so I have to stick with 5.01 till xposed works on 5.1.
The Following User Says Thank You to ih8legal For This Useful Post: [ View ] Gift ih8legal Ad-Free
27th March 2015, 02:03 AM |#4  
Junior Member
Thanks Meter: 1
Thanks a lot!
27th March 2015, 02:51 AM |#5  
HorstiG's Avatar
Senior Member
Flag Banja Luka RS
Thanks Meter: 2,613
Test is running,
Galaxy S5 G900F, Fusion CM12, Boeffla Kernel, BusyBox 1.23.1
27th March 2015, 03:33 AM |#6  
TerryV's Avatar
Junior Member
Flag Innisfail,Ab
Thanks Meter: 8
Letting it soak
Looks good over 10 min letting it soak. Thanks.
27th March 2015, 05:05 AM |#7  
itslels's Avatar
Senior Member
Thanks Meter: 450
Installed and will report back on Saturday. Will say initial tests seem promising.
27th March 2015, 05:14 AM |#8  
ANDR01DN00B's Avatar
Senior Member
Flag Your downstairs basement
Thanks Meter: 802
Actually, there is a need to use it on Custom ROMs like CM. CM just actually implemented a workaround, not a full fix. Just to clarify, you should change that in your post.

The Following User Says Thank You to ANDR01DN00B For This Useful Post: [ View ] Gift ANDR01DN00B Ad-Free
27th March 2015, 05:34 AM |#9  
FuMMoD's Avatar
Recognized Contributor
Flag South Florida
Thanks Meter: 3,078
Donate to Me
Going to test this right now. Thank you

Sent from my Nexus 5 using Tapatalk
27th March 2015, 05:55 AM |#10  
cheeze.keyk's Avatar
Senior Member
Teletubby Land
Thanks Meter: 331
Donate to Me
is cm12 supported?
27th March 2015, 05:56 AM |#11  
gamerman123x's Avatar
Senior Member
Flag Toronto
Thanks Meter: 485
Donate to Me
Originally Posted by cheeze.keyk

is cm12 supported?

Yes it should be
Post Reply Subscribe to Thread

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

Advanced Search
Display Modes