Owners of mid-range and budget smartphones often face the problem of lack of RAM. Applications are unloaded from the background, games are restarted, and the interface begins to slow down when switching between tasks. Manufacturers solve this problem using software methods, and technology has become one of the most effective tools. It allows the system to more efficiently use available resources by creating a virtual buffer for data. ZRAM. It allows the system to more efficiently use available resources by creating a virtual buffer for data.

Many users have heard this term in the specifications of their devices or seen settings with a similar name in the developer menu, but do not fully understand the principle of operation. Essentially, this is a data compression mechanism directly in RAM, which emulates the presence of additional RAM. Unlike the classic page file, which is written to a slow drive, ZRAM works exclusively in the fast memory segment of the processor.

In this article we will look in detail at how exactly this algorithm functions in the ecosystem Android, why it has become a standard for modern shells and how you can manually configure its parameters for maximum performance of your gadget. Understanding these processes will help you extend the life of your device and make it operate more smoothly even under heavy loads.

The principle of operation of memory compression technology

Traditionally, when the RAM is full, the operating system begins to offload inactive processes to the device's internal storage, creating a so-called swap file. The problem with this method is the huge difference in speeds: RAM runs at gigahertz, while flash memory (eMMC or UFS) is much slower. This leads to delays when returning to minimized applications.

Technology ZRAM solves this dilemma in a radically different way. Instead of dumping data onto a slow disk, the system takes part of the RAM and allocates it to a special partition. All data that falls into this section is compressed by algorithms like LZ4 or Deflate before recording. Thanks to this, one physical gigabyte can store up to 2-3 gigabytes of compressed information.

The processor of modern smartphones has enough power to compress and decompress data almost instantly, without creating a noticeable load on the user. As a result, when you return to a background application, the system quickly decompresses it from the compressed block into the main memory pool, and the application opens instantly, without a long loading from disk.

โš ๏ธ Warning: Using ZRAM requires CPU resources for compression. On very old or weak processors (for example, entry-level 5-7 years ago), activating aggressive ZRAM settings can lead to the opposite effect - heating and slowdowns due to a lack of CPU processing power.

It is important to understand that ZRAM does not increase the physical volume of memory chips soldered on the board. This is software optimization that allows you to more effectively manage what you already have. For heavy 3D games that require a continuous stream of data, this method is less efficient than real physical memory, but it is indispensable for multitasking instant messengers and browsers.

๐Ÿ’ก

If your smartphone starts to get very hot during active multitasking, try reducing the size of the ZRAM partition in the developer settings or through specialized applications.

Differences between ZRAM and a classic file swap

To finally clarify the situation, it is necessary to compare two approaches to memory management. Classic Swap (swap file) and ZRAM solve the same problem, but use fundamentally different device resources. The choice between them or their combination depends on the specific configuration of your smartphone.

The table below clearly demonstrates the key differences between these technologies:

Characteristics Classic Swap (on flash memory) ZRAM (on RAM) memory)
Access speed Low (depending on UFS/eMMC) Very high (RAM speed)
Storage wear High (constant record) None (working in RAM)
CPU load Minimum Average (compression required)
Volume efficiency 1 GB of file = 1 GB of data 1 GB of partition = ~2.5 GB of data

The main advantage of ZRAM is the absence of wear and tear on the internal memory of the smartphone. Constantly writing and rewriting a large swap file to a flash drive can reduce its resource over time, although on modern UFS 3.1 and UFS 4.0 this is less critical than on older ones. ZRAM completely eliminates this factor by working in volatile memory. eMMC. ZRAM completely eliminates this factor by operating in volatile memory.

On the other hand, classic Swap can be useful in situations where the RAM is completely full, including the reserved ZRAM block. In this case, the system can use a hybrid approach: first compress the data in ZRAM, and offload the oldest and inactive data to disk. However, in its pure form, it is the compression technology that dominates on modern Android smartphones.

๐Ÿ“Š What is the amount of RAM in your smartphone?
4 GB or less
6 GB
8 GB
12 GB and more

How to check the presence and status of ZRAM on a device

Before making any changes to the system, you need to make sure that the technology is generally active on your device and find out its current parameters. Most modern shells from Xiaomi, Samsung, Realme and other manufacturers include ZRAM by default, but the size of the allocated partition may vary.

The easiest way to check is to use third-party system monitoring utilities, such as CPU-Z or DevCheck. The "Memory" or "RAM" section of these applications often displays information about the ZRAM partition. However, to obtain accurate technical data, it is better to use the built-in capabilities of the system or the terminal.

If you have access to a computer and USB debugging is enabled, you can get accurate information via ADB. Connect your smartphone, open the command line on your PC and enter the following command to view the size of the selected partition:

adb shell cat /sys/block/zram0/disksize

The result will be displayed in bytes. You can also find out usage statistics by entering the command adb shell cat /sys/block/zram0/mm_stat. This will show how much data is currently compressed and how efficient the algorithm is. For users without root access and a computer, there are applications like Swap Checkthat read these system files directly.

It is worth noting that in the latest versions of Android (starting from 11 and above), ZRAM settings are often hidden deep in the menu or automated. The system itself dynamically changes the partition size depending on the available free memory and the current load on the processor.

Configuring ZRAM parameters through the developer menu

On some devices, especially with customization-oriented shells (for example, MIUI, ColorOS, OneUI), manufacturers have moved virtual memory management into the user interface. This allows you to easily enable the "Memory Expansion" function without unnecessary movements.

Usually the path to the settings looks like this: go to Settings โ†’ About phone โ†’ MIUI version (or build number) and click on the item 7 times until the notification โ€œYou have become a developerโ€ appears. After this, a new item will appear in the main settings Advanced โ†’ For developers.

Inside the developer menu, find the section related to memory. It may be called differently: "ZRAM Size", "Memory Extension", "RAM Plus" or "Virtual Memory". Here you will be asked to choose one of several volume options.

โ˜‘๏ธ Check before changing ZRAM settings

Done: 0 / 4

The choice of the optimal size depends on the physical amount of RAM. If you have 4 GB of memory, adding 2-3 GB of virtual memory can significantly improve multitasking. However, if you have 12 GB or 16 GB of physical memory, enabling maximum expansion is often pointless and may even reduce performance due to unnecessary compression operations.

โš ๏ธ Warning: Do not set the ZRAM size equal to or greater than the amount of physical memory. The optimal ratio is from 25% to 50% of the amount of real RAM. Exceeding this limit may cause unstable system operation and frequent reboots.

After changing the parameter, the device will require a reboot. Only after it the new configuration file will be applied by the system kernel. Monitor the behavior of the smartphone in the first hours: if you notice micro-freezes or increased battery consumption, return the settings to the โ€œDefaultโ€ value or disable the function.

What to do if the ZRAM item is not in the developer menu?

If you do not find the setting in the standard menu, this means that the manufacturer has blocked the possibility of manual change. In this case, changes are only possible if you have root access and use specialized modules or scripts, which is not recommended for ordinary users due to the risk of loss of warranty.

Advanced optimization through the terminal and root access

For enthusiasts with superuser rights (Root), it is possible to fine-tune not only the size, but also the compression algorithm. The standard algorithm LZ4 is the most balanced in terms of speed and compression ratio, but in some scenarios other options may be useful.

To change the settings manually, you will need a terminal emulator installed directly on your smartphone, or a connection via ADB with root access. First, you need to gain privileged access by entering the command su and confirming the request in the rights manager (Magisk, KernelSU).

Next you can change the compression algorithm. The available algorithms depend on the kernel version of your device. You can view the list of available ones with the command:

cat /sys/block/zram0/comp_algorithm

To install, for example, an algorithm zstd (which provides a better compression ratio, but requires more CPU resources), use the command:

echo zstd > /sys/block/zram0/comp_algorithm

You can also dynamically change the partition size without rebooting. The command takes a value in bytes. For example, to set the size to 2 GB (2147483648 bytes), enter:

echo 2147483648 > /sys/block/zram0/disksize

To make them permanent, you need to create an initialization script (init.d) or use the Magisk module, which will apply these commands every time the system starts.

๐Ÿ’ก

Manually setting the compression algorithm makes sense only on powerful processors. On budget chips, leave the standard LZ4 for maximum interface responsiveness.

The influence of ZRAM on device autonomy and heating

Any optimization has its price. In the case of ZRAM, this cost is the additional processor cycles spent compressing and decompressing the data. Although modern algorithms are very efficient, they still consume energy and generate heat.

During active multitasking, when the system constantly accesses the ZRAM partition, the load on the CPU cores increases. This can be noticeable in scenarios where you are quickly switching between heavy applications. On devices with passive cooling or a weak heat dissipation system, this can lead to noticeable heating of the case in the upper part.

From the point of view of autonomy, the influence of ZRAM is ambiguous. On the one hand, preventing applications from being swapped out to disk and then completely rebooted saves energy, since starting an application from scratch requires more resources than restoring it from a compressed state. On the other hand, the constant background work of the processor to maintain ZRAM can cause a small additional expense.

In most modern use cases, the balance is tipped in favor of savings. Quickly restoring apps from ZRAM allows the user to lock the screen faster, which ultimately extends battery life. Heating problems arise mainly due to incorrect settings (too large amount of ZRAM on a weak processor).

โš ๏ธ Attention: Interfaces and names of settings may differ depending on the version of Android and the manufacturer's shell. If you do not find the described items, check the official documentation for your smartphone model or contact the brand support forum.

Frequently asked questions (FAQ)

Will ZRAM increase performance in games?

No, ZRAM is not designed to increase FPS in games. Games require continuous access to large amounts of data, and real-time compression/decompression can even cause micro-stuttering. ZRAM is useful primarily for multitasking and keeping applications in the background.

Is it possible to completely disable ZRAM?

Yes, it is possible. The developer menu often has a "Disable" option or a "0 GB" size selection. If you have root access, you can also unload the kernel module responsible for the operation of zram, but this is not recommended without compelling reasons, since the system may become less stable if there is insufficient memory.

Does using ZRAM harm the life of a smartphone?

On the contrary, using ZRAM extends the life of internal flash memory. Since data is not constantly written to the drive (as is the case with a classic swap file), the number of rewrite cycles of memory cells is reduced, which has a positive effect on the longevity of the device.

Why did there be less free memory after turning on ZRAM?

This is normal behavior. The system reserves part of the physical RAM for the ZRAM partition. Even if it is empty, it takes up address space. However, thanks to compression, more data fits into this โ€œreservedโ€ piece than into a regular memory section of the same size.