Huge battery drain / memory leak on android


#1

What is the best way to go about hunting down a memory leak on android? We are getting massive battery drain on a few android devices… to the point where it drains so fast that the phone can’t be charged quick enough and eventually runs out of juice entirely.

Hunting these kinds of things is not something we’ve had to do before now so any points at good guides or debugging ideas are really really welcome :slight_smile:


#2

Well it’s either in your webview (e.g. your code) or natively in plugins. To potentially eliminate the former, you could use chrome dev tools to take a snapshot of whatever activity is contributing to the drainage issue and figure out if that’s your problem, and try to optimize. If your webview isn’t draining the battery, you’ll have to pick through your plugins to find the culprit


#3

Yeah its a tough call for this one. Like @premiumfrye said, you should first dig though your js to make sure there isn’t any leaky code. For the native side, you may have to open xcode/android studio to get some logs and see if there are any errors showing up.


#4

Thank you both - I guess what I am really getting at is any guides to actually performing the tasks you note. How to dig into there / use the tools available and what I am even looking for to identify the issues / measure changes to know if it is better or worse. I’d already figured it was going to be javascript or native, but I have no experience tracking down anything within those / using the tools and hope someone might know of a good intro guide to the tools in the context of a web view based mobile app :slight_smile:


#5

Hi there,

we also had to dig into that kind of tools because of a similar issue we are currently facing on ios.

Here are some interesting resources we have found for the occasion :

Dev tools :

Potential JS memory leaks :

Hope this can help you.
Regards.


#6

Thank you all so much.

One (hopefully) final point / question … we are noticing CPU stuck high and wondered if there are any good routes for tracking down the culprit for high CPU usage even when idle on android?