Android is an operating system that is constantly evolving, but even on modern devices users are faced with a lack of RAM. One of the tools that helps deal with this problem is ZRAM (or zSwap). This is a technology for compressing data in RAM, which allows you to โ€œunloadโ€ the system without using a physical drive.

If your smartphone starts to slow down when multitasking or applications are often reloaded, it may be a problem with RAM. ZRAM creating a virtual partition in memory where data is compressed in real time, saving space for new tasks. But how does this work in practice? And is it possible to manually tune ZRAM for better performance? In this article we will understand all the nuances - from theory to practical advice.

What is ZRAM and how did it appear in Android

The technology ZRAM (previously known as compressed RAM or zSwap) was borrowed from the core Linuxon which it is built Android. Its main task is increase the effective capacity of RAM without physical expansioncompressing unused data on the fly. Unlike the classic swap, which writes data to disk, ZRAM works directly in RAM, which significantly speeds up access to them.

B Android ZRAM appeared in other versions 4.x, but began to be actively used with the release Android 7.0 Nougat and later. Today it is enabled by default on most devices with 4 GB RAM or smaller, and on flagships with 8+ GB it can be disabled or run in a gentle mode. Manufacturers like Samsung, Xiaomi and Google adapt ZRAM to their firmware, sometimes changing compression algorithms or the size of the virtual partition.

  • ๐Ÿ“ฑ What is ZRAM for? โ€” To avoid โ€œkillingโ€ background applications when there is not enough memory.
  • โšก Advantage over swap: No delays due to writing to disk (all data remains in RAM).
  • โš™๏ธ How it works: Compresses inactive memory pages in real time (compression ratio ~2-3 times).

It is interesting that on some custom firmwares (for example, LineageOS or Pixel Experience) users can manually configure ZRAM parameters - from the partition size to the compression algorithm (lz4, zstd, lzoHowever, on stock ones). In firmware, such options are usually hidden.

๐Ÿ“Š Have you ever heard of ZRAM before this article?
Yes, I used it
I heard, but I donโ€™t know what it is
No, I found out for the first time
I donโ€™t know, but I want to configure

How ZRAM differs from classic swap (swap)

Many people confuse ZRAM with the traditional swappartition, but there are fundamental differences between them. Classic swap uses part of the internal memory (ROM) or microSD to store data that does not fit in RAMThis leads to two problems:

  1. ๐Ÿข Slow operation: Reading/writing to flash memory is hundreds of times slower than accessing RAM.
  2. โš ๏ธ Wear of the drive: Frequent overwriting data reduces the service life eMMC or UFS.

ZRAM solves both of these problems, because:

  • ๐Ÿ’จ Works in memory: Data is compressed and stored directly in RAM, without accessing the disk.
  • ๐Ÿ”„ Dynamic management: The size of the virtual swap adjusts to the load (unlike a fixed swap partition).
  • ๐Ÿ›ก๏ธ Security: There is no risk of data loss due to a sudden power outage (unlike swap on the disk).
Parameter ZRAM Classic swap
Storage location RAM (RAM) Internal memory (ROM)
Access speed Instant (like RAM) Slow (like a disk)
Wear of the drive No influence Accelerates wear flash memory
Size adjustment Dynamic or manual Fixed during creation

However, ZRAM also has disadvantages. For example, data compression requires additional computing resources, which can slightly increase the load on the processor. (for example, with Qualcomm Snapdragon 4xx or Mediatek Helio A22) this sometimes leads to increased battery consumption.

๐Ÿ’ก

If your smartphone is heating up for no apparent reason, check the CPU load using the application CPU MonitorPerhaps the ZRAM is compressing data too aggressively.

How to Check if ZRAM is Enabled on Your Android

By default, ZRAM is activated on most devices with 4 GB RAM or smaller, but some manufacturers (for example, OnePlus or Realme) disable it on flagships. You can check the status of ZRAM. in several ways:

Method 1: Via ADB (for advanced users)

Connect your smartphone to the PC, enable USB Debugging in the developer settings and run the command:

adb shell cat /proc/swaps

If the output contains a line with /dev/block/zram0, then the ZRAM is active. To see usage statistics, enter:

adb shell cat /proc/meminfo | grep -i zram

Method 2: Through applications

Install one of these applications from Google Play:

  • ๐Ÿ“Š DevCheck - shows information about memory, including ZRAM (section Memory).
  • ๐Ÿ” CPU-Z - tab Memory displays swap and compressed memory.
  • ๐Ÿ› ๏ธ Kernel Adiutor (requires root) - allows you to manage ZRAM parameters.

On some firmware (for example MIUI or ColorOS), information about ZRAM can be hidden. In this case, only ADB or root access will help.

What to do if ZRAM is disabled?

On stock firmware enabling ZRAM without root is almost impossible. However, on custom firmware (for example, LineageOS) this is done by editing the file /etc/init.d/ or the kernel. Be careful: incorrect settings can lead to bootloop!

How to manually configure ZRAM for better performance

If you have there root access, you can optimize ZRAM to suit your needs. Here are the key parameters that you can change:

  1. ๐Ÿ“ ZRAM size: The default is usually 50-100% of physical RAMOn weak devices (for example, Redmi 4A s 2 GB RAM) can be increased to 150%, but this will increase the load on the CPU.
  2. โš™๏ธ Compression algorithm: Modern cores support zstd (better compression, but high load), lz4 (balance of speed and compression) and lzo (fastest, but weak compression).
  3. ๐Ÿ”„ Priority swap: Parameter swappiness (from 0 to 100) determines how actively the system uses ZRAM. Value 60 is standard for Android.

To change parameters, use Terminal Emulator or ADB. Example commands:

# Set ZRAM size (for example, 2 GB)

echo 2147483648 > /sys/block/zram0/disksize

Change compression algorithm to lz4

echo lz4 > /sys/block/zram0/comp_algorithm

Configure swappiness (requires superuser rights)

echo 80 > /proc/sys/vm/swappiness

Make a backup of current settings|Check free space in /system|Change parameters one at a time, testing stability|Monitor the processor temperature after changes-->

โš ๏ธ Attention: Incorrect ZRAM settings can lead to unstable operation of the system or even bootloop. If after the changes the smartphone starts to overheat or shut down, return the settings to default values.

On devices without root, the only way to affect ZRAM is to use firmware with pre-optimized settings (for example, Havoc-OS or Corvus OS). Some custom kernels (for example FrancoKernel or ElementalXalso offer advanced options for managing compressed memory.

ZRAM and battery: does memory compression affect autonomy

One of the common myths is that ZRAM increases battery consumption. In fact, it all depends on the device and the load:

  • โšก On weak processors (for example, Snapdragon 425 or Helio P22) data compression can add 5-10% load to the CPU, which slightly reduces the time work.
  • ๐Ÿ”‹ On flagships (for example, Snapdragon 8 Gen 2 or Dimensity 9000) the impact of ZRAM on the battery is minimal, since processors cope with compression without noticeable costs.
  • ๐Ÿ“‰ With active multitasking ZRAM, on the contrary, saves energy, as it reduces the number of application restarts (which waste more battery than background compression).

To check the impact of ZRAM on autonomy, use the application AccuBattery or GSam Battery Monitor. Compare battery consumption with ZRAM enabled and disabled (if your firmware allows it). On most devices, the difference is no more 1-3% per day.

โš ๏ธ Attention: If, after activating ZRAM, the smartphone begins to heat up when idle (for example, in standby mode), it is likely that a too resource-intensive compression algorithm was selected (for example, zstd). Try switching to lz4.
๐Ÿ’ก

On most modern smartphones, ZRAM has a minor impact on the battery, but significantly improves multitasking. The optimal balance is the algorithm lz4 and the ZRAM size within 50-100% of the physical RAM.

Problems with ZRAM and how to solve them

Although ZRAM usually works stably, sometimes users encounter problems. Here are the most common ones and how to fix them:

Problem Possible cause Solution
Smartphone slows down after activating ZRAM ZRAM size is too large or aggressive algorithm compression Reduce the size to 50% of RAM, change the algorithm to lz4
Applications are restarted more often Low value swappiness (for example, 10-20) Increase swappiness to 60-80
Increased battery consumption CPU is constantly busy with compression/decompression Switch to a less resource-intensive algorithm or reduce the ZRAM size
ZRAM does not turn on after firmware There is no support in the kernel or a conflict with other modules Check kernel compatibility, update the firmware

If after changing the ZRAM settings the smartphone begins to behave unstable (for example, reboots spontaneously), return the parameters to the values according to default. On some devices (especially those with processors), ZRAM may conflict with functions like In this case, you will have to choose between these technologies. Mediatek-processors) ZRAM may conflict with features like Memory Fusion (y Xiaomi) or RAM Expansion (y Samsung). In this case, you will have to choose between these technologies.

Conflict between ZRAM and RAM Expansion

Function RAM Expansion (virtual memory from ROM) and ZRAM solve one problem - increasing the available memory. Using both technologies at the same time may result in unstable operation. If your device supports both, choose one (preferably ZRAM, as it is faster).

ZRAM vs RAM Expansion: which is better for your smartphone

Many manufacturers (for example, Samsung, Xiaomi, Oppo) offer the function RAM Expansion (or Virtual RAM), which reserves part of the internal memory (ROM) for RAM. At first glance, this is an alternative to ZRAM, but in fact they have different approaches:

  • ๐Ÿ’พ RAM Expansion: Uses ROM (slower, but does not load the CPU). Suitable for devices with UFS 3.1 and fast flash memory.
  • ๐Ÿง  ZRAM: Works in RAM (faster, but requires computing resources). Optimal for weak processors with a small amount of memory.

Which option to choose?

  • ๐Ÿ“ฑ For budget smartphones (for example, Redmi 9A s 2 GB RAM) โ€” ZRAM is preferable, since eMMCmemory is too slow for RAM Expansion.
  • ๐Ÿš€ For flagships (for example, Galaxy S23 Ultra s 12 GB RAM) โ€” RAM Expansion may be useful if you run resource-intensive games (for example, Genshin Impact).
  • โš–๏ธ For average segment (for example, POCO X5 Pro s 6-8 GB RAM) - it is better to disable both functions, since physical memory is usually enough.

On some firmware (for example, HyperOS from Xiaomi), you can simultaneously activate both ZRAM and RAM Expansion, but this rarely gives a performance increase. As a rule, one is enough. from technologies.

FAQ: Frequently asked questions about ZRAM on Android

โ“ Is it possible to enable ZRAM without root?

On most stock firmware, ZRAM is not controlled at the kernel level, and to configure it, superuser rights are required. The exception is some custom firmware (for example, LineageOS), where ZRAM is enabled by default.

โ“ What is the optimal ZRAM size for a smartphone with 4 GB RAM?

Recommended size - 1-1.5 GB (25-50% of physical memory If you use a lot of background applications (for example, instant messengers + music +). navigator), can be increased to 2 GB, but watch the load on the CPU.

โ“ Is ZRAM harmful for the processor?

On modern chips (for example, Snapdragon 8xx or Dimensity) - no. Data compression takes less 5% CPU resources. On weak processors (for example, Helio A20) it can add load, but usually this is less critical than lack of memory.

โ“ Why is ZRAM disabled on my smartphone with 12 GB RAM?

Manufacturers often disable ZRAM on devices with large amounts of memory, since it is less in demand there. For example, Samsung and Google do not activate ZRAM on flagships. s 8+ GB RAM, assuming that there will be enough physical memory for all tasks.

โ“ Is it possible to use ZRAM together with RAM Expansion?

Technically yes, but this rarely provides benefits. RAM Expansion and ZRAM solve one problem - increasing available memory, but in different ways. Simultaneous use can lead to conflicts or excessive load. It is better to choose one or the other.

If your question is not covered in the FAQ, check the documentation for your firmware or kernel on forums like XDA Developers or 4PDA The nuances of ZRAM settings for specific models are often discussed.

โš ๏ธ Attention: ZRAM parameters may differ depending on the version of Android and firmware. For example, Android 14 some paths to configuration files have changed. Always check the latest data for your device.