[Moto G4 ROMs, Kernels, Recoveries, & Other Develop] EarlyMon:
Hi. :)

You're correct about zram overall up to the point that it helps by giving use for unused ram.

Let's clarify for everyone's sake.

Swap is virtual memory strategy to augment available RAM.

It first appeared for most people on desktops using a portion of the hard drive to emulate RAM, and (simplified version) swapped the contents of RAM with the local storage set aside for that, back and forth as needed - to assist with better overall multitasking, and for that it worked a treat. (It actually first appeared on mainframes and then minicomputers for those with OCD.)

Android is a real-time Linux implementation and Linux has virtual memory strategies including swap as part of its mainframe heritage.

2010 saw the rise of the superphones with an astonishing 512 MB of RAM on board - with most Androids having far less - and then take away some for hardware functions, then the operating system, and what was left was yours for apps.

I've been using Android since 2009 and I don't remember who started it or when, but by the summer of 2010, adding swap to an Android by repartitioning the SD card and exploiting that the kernel already knew how to use it for swap if done right had become a darling mod.

Eventually phones got enough ram to outgrow it (and while popular with many, the mod was never universally accepted as the right thing to do) but manufacturers kept producing cheap phones without sufficient hardware resources (still do, sadly) and so the mod never actually died gracefully.

And let's stay in the real world - Android is a compact, real-time Linux - it's not a desktop Linux distribution and it was specifically designed for mobile use.

Enter the Dalvik virtual machine, the cornerstone that makes Android different from a desktop, and it's post-KitKat replacement, the Android Runtime.

Either way, let's call that the Android machine.

And what it does is provide the app environment with the job control and RAM management for apps within a closed system, above the kernel, and it does everything you need for shuffling apps around and optimizing your multitasking experience.

It doesn't need any help, all things being proper.

But things aren't always proper and starved phones continue to be made.

Enter Qualcomm.

They provided a shell script to add swap back on for phones choking with less than 1 GB of RAM on board in hardware.

It's in /system/etc/init.qcom.zram.sh on your new Moto and it's what I provided the patch for.

Initially, it tested to see if a phone had less than 1 GB RAM and do nothing if 1 GB or larger, otherwise, set up and launch zram.

And all zram is is a set aside in RAM that's used for swap through the magic of compression and decompression to try to get the appearance of more RAM.

This sounded so great on paper that this travesty has been adopted by flagships and the Nexus and Google has even codified it for manufacturers with what they consider to be appropriate guidelines for implementation.

Frankly, it's change for change's sake by developers who have no full grasp of the history of Android swap and live in a theoretical world without looking at what it really does to user performance in the face of a larger Android needing more RAM in the first place, on less than ideal mobile processors.

Android already does multitasking management without giving the processor a redundancy with compression and decompression lying to it about available RAM and it's highly optimized after years of ongoing refinement.

Zram is a moving target that fails often (Nexus 6P owners who don't get rid of it like to reboot their phones every few days to restore speed, something not needed by people who have taken the cure, thanks to entropy with zram processing) and manufacturers think that this lipstick will look even more red on the pig if they increase the compression ratio.

Stealing CPU resources that you need a lot more than you need RAM.

Go ahead and look in /system/etc/init.qcom.zram.sh on your Moto - please don't take my word for it.

Moto has followed in the new Chinese tradition of changing what that file does, ignoring that Qualcomm said in the comments, in plain English, to only do this for phones without enough RAM.

The Moto doesn't qualify and doesn't need it by design.

You can also see that all it does is call the toybox command to turn it off right after boot, at the end of initialization.

I left the original Moto contents in place because the OP asked late at night for some help when Kernel Adiutor took the turn-off feature away and I never got back to help with something that looked prettier. (And nothing bad on Kernel Adiutor, zram implementation and proliferation is getting to be a burden for maintenance, I don't blame them.)

Past the comments, Moto did not leave the original Qualcomm code in place.

The canonically correct no-swap fix for your phone would be to go in to the ramdisk in the boot image and remove where it gets turned on in the first place.

And then have to redo the mod every time Moto updates that.

Ain't nobody got time for that, and I don't own this phone, I'm helping friends solve this problem with the easy button.

My method leaves the zram declaration in place (you can see it in /proc/partitions) but it's harmlessly unused after the mod.

To learn more about the state of your memory and get some simple explanations without all the voodoo, check out "RAM Truth"

https://play.google.com/store/apps/details?id=sa.ramtruth

It doesn't spy on you, it has no ads or tricky revenue games, it's something that two of us provided as a labor of love for the Android community because after a lot of years, we were repeating the same answers to the same questions.

Knowledge is power ok.

And if you disagree with me about how zram sucks and needs to have a stake driven through its heart, flash the bit that restores your phone to the way it was when you got it and enjoy it in good health. About one in a thousand go that way and that's fine. No need for debate.

Android is all about choice. ;)

Hope this clarifies, thanks for reading, sorry for typos, this was all just flow of consciousness without editing. :p