← Back to team overview

ubuntu-phone team mailing list archive

Re: Memory..

 

On Sat, Jul 16, 2016 at 8:25 PM, รัชนันท์ ศรีรัตนเมธ
<peathot@xxxxxxxxxxx> wrote:
> Hello,
>
> I port Ubuntu Touch to LG L90 Dual which has 1 GB of memory. This means I
> also suffer from all problems about memory people have with BQ Aquaris 4.5.
> Being somewhat experienced with the system, I believe that the problem
> happens from at least 2 reasons:
>
> 1.Management of suspended application's process and Ubuntu touch's usage of
> lowmemorykiller. For those unfamiliar with Android's lowmemorykiller, it's
> mechanism used for selecting which process to kill under low memory
> situation using some parameter like oom_adj value and memory usage of that
> process.
> In Android, oom_adj for each process is computed (by ActivityManager) from
> how important that process is, what application is using that process, how
> recent that application was suspended, etc. As far as I know, Android adjust
> oom_adj so that recently suspended application will have lower oom_adj (less
> likely to be killed), at least for just-suspended application. I'm not the
> specialist though, so please correct me if I'm wrong.
> In Ubuntu touch, I have no idea where oom_adj is computed. (Please anyone
> tell me?) But from my experiment, all suspended applications have the same
> value of oom_adj. How this affects the problem? Imagine this:

You are almost right, but we are not using Android's lowmemorykiller, yet.
Instead, we configure the vanilla OOM killer by altering oom_score_adj
(oom_adj is deprecated).

Android's lowmemorykiller sits on top of this mechanism and allows for
specifying ranges of memory
and mappings to oom{_score}_adj values.

As you describe later, we are not yet deploying a heuristic that
assigns a higher oom_score_adj value
to app instances that have been used less recently (think about: least
recently used is more likely to be killed under the assumption
of a uniform distribution of memory usage). The respective feature is
under development iirc, but I'll
let Gerry and Ted comment on this explicitly (I CC'ed both of them explicitly).

>  * A few application using not much memory is suspended.
>  * You launch a web browser, which, of course, use significant memory.
>  * Then, you swipe the web browser into the background and launch Dekko.
> Dekko also uses significant memory.
>  * Now, lowmemorykiller kicks in and decide which process should be killed.
> Ideally, it should kill those not recently used first. But, as all suspended
> application have same oom_adj value, lowmemorykiller have to decide what to
> kill by its memory usage, and, as you might guess, the candidate is the web
> browser.
> I believe that if lowmemorykiller kills processes in first point, there will
> be enough memory for the web browser and Dekko.
> I also believe that this causes one of the bug I observed on my phone. It's
> about having browser killed while waiting for a picture from gallery app.
> Have a look at
> [https://bugs.launchpad.net/ubuntu-application-lifecycle/+bug/1596059]. If
> people using BQ 4.5 can reproduce this bug, please upvote the bug by
> clicking "Does this bugs affects you?" on top of the page.
>
> 2.Ubuntu touch's choice for using QML. Out of curiosity, I opened an SSH
> session, ran "top", and looked at the calculator app's memory usage on my
> phone. I found out it's around 113 MB. 113 MB just for a caculator!? I'm
> speechless.
> I believe this can be reduced somehow. One of the idea is that, as many QML
> component in Ubuntu is shipped as source .qml files, I understand that each
> application will have to load those files, parse that files, and keep those
> parsed code individually in each application's memory (please correct me if
> I'm wrong). As many Android kernel has enabled KSM (kernel samepage
> merging), maybe we should try exploiting it? I've tried enabling KSM on my
> device, but the result was pretty disappointing. Maybe we should mark those
> memory as  mergeable?
>

I think we should take the time and analyze memory usage first before
starting to optimize.
Specifically, for the reported 113 MB, is that RSS, USS or PSS?. I
don't have a phone with ssh handy right now
but I will try to reproduce your test case tomorrow first thing. I
would start analyzing /proc/$pid/smaps first.

I would also propose to establish a memory baseline measurement by
considering a very simple QML app just displaying a rectangle.
That should give a reasonable baseline for comparisons. Even if the
calculator is simple, it still puts its own app logic on top (stack of
calculations etc.).


> Sorry for a rather long e-mail, but I just want to share my though about how
> low memory situation could be resolved. Maybe all I've said is a crap, then
> please give me the correct knowledge.
>

On the contrary: Thanks for your thoughts and ideas :)

Cheers,

  Thomas

> Ratchanan Srirattanamet
>
> PS. It seems like browser session won't restore after being killed in
> background on my device. Does it works on other device? rc-proposed build
> 20160715-092035.
> On 16/07/2559 16:31, Simplehuman wrote:
>
> I'm Meizu MX4 user with 2 GB of RAM on rc-proposed. Problems are the same as
> you described
>
> 15.07.2016 23:26, Eran Benjamin пишет:
>
>
> I get the same in BQ4.5, and it does seem to be happening more since OTA11,
> I cannot run two "heavy" apps without other apps exiting.
>
> Apps just become some bad res jpeg of their last screen view, which gets
> refreshed when I click on the app again.
>
> I also assumed it's mem limitation, but are we sure it's a ram issue and not
> how the OS handles multiple apps?
>
> Right now my SIM card is in the BQ, but I have to rely many times on a
> tag-along tethered android phone for basic daily tasks, for example: The BQ
> can either play music to my car stereo via bluetooth, or run unav without
> getting stuck mid route, not both.
>
> I got a vanilla install with only Daniel Wood's Owncloud-sync extra (the mem
> issues were before the extra app was installed).
>
> Am also curious to hear Meizu owners if more ram solves it.
>
> Is getting Ubuntu touch to run on a rooted android phone a complex
> operation? Does it have to be from specific chipsets?
>
> Eran
>
> On 15-07-16 18:53, Wayne Ward wrote:
>
> I'm looking at maybe getting rid of the e5 as the what I think is low memory
> is driving me mad! I'm thinking this has one gig of ram and its not enough?
> It used to be but now always seems to be low on memory.
> I have a clean install with the following installed and obviously running in
> background
>
> Rockwork
> Owncloud
> Now i have dekko running unconfined for email notifications to pebble
> And sometimes music appeared open all the time to play from pebble when I
> want.
>
> The problem is I get reload on facebook, browser, gmail or twitter and dekko
> just closes itself when it feels like it. It only started doing this since
> say ota10.
>
> I noticed the meizu has 3 gig of ram. I'm just wondering if meizu users get
> the same problem as they have more memory?
> I really love my bqe5 but its getting annoying now to be honest. Don't want
> to switch back to android, been here from the beggining, cant use unav as
> that just white screens after 5 or 10 mins as well
>
> In my mind more memory is required or am I wrong and all the phones do the
> same.. I dont mind shelling on a new meizu as long as I get rid of this
> nigly problem thats just stoping me enjoying the phone and OS I love and got
> used to now ?
>
> Is there maybe away to streamline the E5 phone like turn of a upatart app
> any suggestions please its wearing thin now, specially after todays proposed
> updated killed my phone and wiped it just to get the same reload problem
> I can video this and put it on my blog if anybody needs to see what I
> mean...
>
> Wayne
>
>
>
>
>
>
>
> --
> Mailing list: https://launchpad.net/~ubuntu-phone
> Post to     : ubuntu-phone@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~ubuntu-phone
> More help   : https://help.launchpad.net/ListHelp
>


Follow ups

References