Android Oreo 8.1 - Need to increase swap space (increase total memory by allocating more of its storage)

Hi all
I work for a OEM phone vendor. We have a prospective client that wants more RAM in a certain model Android Oreo 8.1 phone to prevent Android’s memory manager from closing the least recently used and RAM-hungriest apps. I propose to provide that by extending the swap partition (thus creating more swap memory) from the existing 0.5GB to 1.5 or better still 2.5GB. The storage is eMMC and there is enough storage (and fast storage) for what I want to do.
Most likely I need to change the partition structure and to do so I expect to have to root the phone. But I also need to be able to “unroot” the phone after. I cannot supply my client with rooted phones. But the other way to do it would be to somehow specify, a swap file (like Windows) on existing partitions. Is that possible? In this way, maybe root is not required? Don’t know.
Either way, additionally, I would like to do this from a command line in order to automate it – hopefully with an MDM/EMM; but that might be “dreaming”.
The volumes are not huge, and therefore, our overseas factory does not want to get involved.
Can anyone help me, please?
Cheers Mikhael
mikhaelSales EngineerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Brandon LyonSenior Frontend DeveloperCommented:
I found a pretty good walkthrough for adding a swap file to android.

I haven't tried it myself but it looks pretty comprehensive. The downside is that you would need root, but the upside is that should only be for the initial setup. Your device's Android kernel will also need to support swap. There are options for doing this via command line or via third party app.
mikhaelSales EngineerAuthor Commented:
Thanks Brandon, I'll check it out
Jackie Man IT ManagerCommented: extending the swap partition (thus creating more swap memory) from the existing 0.5GB to 1.5 or better still 2.5GB.

Why you think that your phone has a swap partition of 0.5GB?

My SAMSUNG S7 Edge has a 2GB swap partition.

It is not a good idea for your rooting and unrooting approach.

The better approach is to specify the minimum and recommended requirements for memory (RAM)..

It is common to buy a phone with at least 3GB or 4GB memory these days.
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

Brandon LyonSenior Frontend DeveloperCommented:
It is common to buy a phone with at least 3GB or 4GB memory these days.

Depending on what you're doing that might not be enough. I find that 6GB is the minimum I need from an Android phone before it starts to close apps that I don't want it closing, and that's just from day to day usage. I had to ditch my Pixel 2 for that reason.
mikhaelSales EngineerAuthor Commented:
Sorry to take so long guys. I'm not ignoring you :)
I'm waiting for an "expendable" device to work on. Could be another week or so.
Jackie Man IT ManagerCommented:
Any progress?
mikhaelSales EngineerAuthor Commented:
Again sorry to take so long.
Brandon, I'm still waiting for an "expendable" unit to work on :(   Anyway, according to your referenced pages, it seems I can root, then "unroot" the phone. And separately, I am really keen to try zram and zswap as well.
Jackie Man, I know it is common to buy a phone with 3 or 4GB or more. And I wish I did have the ability to specify a larger memory (or storage either). However, this model only has the one spec.
I know it has 0.5GB swap currently because I am able to interrogate the phone with the ADB command from my PC (the command is free -h). See attached screenshot.
Hope this helps.
Stay tuned guys.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.