The surprising part of zram is not that it compresses data. It is that a computer can send pages toward something presented as a disk and still keep their stored representation in RAM. At first that sounds like moving objects from one pocket to another and claiming to have found more space. The missing detail is the form of the objects. If the pages can be represented with fewer bytes, the move can release room elsewhere in memory while retaining the information needed to reconstruct them. The gain is real under suitable contents, but it is a gain from representation, with costs and limits of its own.
There is no new physical memory hidden behind the name. The Linux zram documentation describes RAM-based block devices. Data written to them is compressed and stored in memory itself. The block-device interface lets other parts of the system use the device in supported ways, including as swap storage. That role is why a disk-shaped entry can appear in a system whose real storage hardware has not changed. The interface says how requests are addressed. It does not, by itself, tell a person which physical medium holds the representation of the requested data.
Imagine a stack of papers with many repeated phrases. A compact description of those phrases can occupy less space than a literal copy of every mark, provided someone retains the method needed to expand it. Another stack may contain irregular information that resists the same compression. This is only an analogy, but it supplies the essential asymmetry: the outcome depends on content. A program cannot create a fixed amount of extra RAM merely by advertising a large zram device. The pages sent there still have to be represented, and the actual representation determines how much physical memory is consumed.
The size on the device is not the size in the allocator
The advertised disksize describes logical capacity. It is not a promise that the device preallocates an equal amount of physical RAM when initialized. Nor is it a statement that the machine can always fill the entire logical capacity regardless of the compressibility of its future pages. The distinction is familiar in other storage abstractions, but particularly important here because the backing resource is the same RAM whose pressure the arrangement may be intended to relieve. A large logical address range is a capacity interface. Real allocations grow as the device stores actual contents under its supported behavior.
The documentation exposes several statistics that tell this story more accurately than a single compression percentage. orig_data_size concerns the original amount represented. compr_data_size concerns compressed data size. mem_used_total concerns actual memory allocated for the device’s stored data, including effects such as allocator overhead and fragmentation. These quantities share a subject, but they do not have identical boundaries. A ratio using compressed payload alone can look better than a ratio using the total memory required to hold that payload. Both can be calculated correctly; only the definitions explain which question each answers.
Take an invented accounting example. The device represents 1024 MiB of original data. Its compressed payload occupies 400 MiB, while the reported total allocated memory is 480 MiB. Dividing original by compressed payload yields 2.56. Dividing original by allocated memory yields approximately 2.13. The difference is not missing data or a dishonest compressor. It is the difference between counting the payload and counting its full stored allocation under the chosen statistics. The values are teaching assumptions. No zram device was created or measured for this article, and the ratios do not predict the behavior of an application not represented in the example.

The accompanying illustration keeps those accounts separate. It shows the assumed original, compressed, and allocated quantities without turning their difference into a benchmark. The extra allocation in the example is not assigned to a universal fixed metadata percentage; real behavior depends on the representation and allocator state. This matters when a workload changes. Pages with a different pattern can alter the compressed size and the efficiency of allocation. A previous favorable ratio is evidence about the previous contents, not an unconditional exchange rate at which the operating system can trade ordinary pages for physical RAM forever.
Some pages contain the same value repeatedly. The zram implementation can use special handling for same-filled pages rather than storing their entire literal contents in an ordinary compressed allocation. Other pages are incompressible enough that their treatment differs. The statistics have names for supported categories, and those names should be interpreted through the documentation. In particular, the zram huge_pages counter concerns incompressible pages; its name does not make it a count of the memory-management feature called transparent huge pages. Similar words can describe different implementation subjects. Reading the counter’s definition prevents a false connection between a compression observation and page-allocation policy.
The processor joins the conversation
Compression and decompression use computation. A page that occupies fewer stored bytes still needs to be reconstructed when its consumer requires the original contents. A workload that repeatedly moves a changing set of pages through this path can therefore exchange some storage pressure for CPU work and latency. That can be a useful exchange, but it should be described as one. The mechanism does not promise that every access becomes faster or that the CPU cost is invisible. The relevant outcome belongs to the application under actual memory pressure, rather than to the ratio alone.
This is also why the compression algorithm is part of the condition. Supported algorithms can offer different relationships between compression work, decompression work, and resulting size. A setting chosen for one kind of page contents may behave differently for another. The documentation describes how algorithms are selected and, on supporting implementations, how related parameters can be managed. The existence of these controls does not establish one universally best choice. The application needs a useful balance under its own contents and access pattern. A beautifully small representation is not automatically valuable if the work required to produce or repeatedly recover it dominates the task.
The story becomes less tidy when someone says that zram means no disk activity. The core arrangement is RAM-based, but optional writeback facilities can move selected contents to configured backing storage when supported and enabled. That is a different configuration from retaining everything solely in RAM. A description of one must not silently borrow the other’s properties. The documentation marks such behavior as conditional on implementation and setup. It is enough here to understand that the device name alone does not certify the complete physical destination of every byte under every possible configuration.
Recompression is another conditional extension rather than a new physical medium. A supporting implementation can attempt to represent selected data differently using its configured algorithms and rules. The resulting work has a purpose: improve how memory is used for data already present. It also consumes resources and requires the supported configuration. One should not infer from the presence of a documented feature that every installed kernel exposes it in the same form. The mechanism belongs in a description of an actual system only when that system’s capabilities and state have been established. This article supplies no deployment claim about an uninspected machine.
At this point zswap often enters the conversation under a similar name. The Linux zswap documentation describes a compressed cache for swapped pages, with a relationship to backing swap storage. That differs from zram’s presentation as a RAM-based block device that can itself be used for swap. Both involve compression and memory pressure, but their roles in the storage path are not identical. Calling them synonyms makes it difficult to explain where pages can eventually go and which component owns their representation. The right name preserves the architecture that gives each mechanism its purpose.
An application user may not care about those names until a pause appears. Then the distinctions help interpret what might be happening. A pause associated with memory pressure can involve reclaim, compression, page recovery, or access to configured backing storage, depending on the arrangement. A favorable compression ratio alone cannot diagnose the pause. Nor can the mere existence of a swap-device entry prove that the machine is waiting for a rotating disk. The same interface role can be implemented through different physical paths. The observation needs to be connected to the actual path before it becomes an explanation of elapsed time.
There is a hard limit to the pocket analogy. RAM storing compressed pages remains a finite, volatile resource. It also competes with other demands for memory. If new contents need more space than the arrangement can provide, the block-device abstraction does not create unlimited backing. Memory limits and error handling remain important parts of the implementation. A service should not be described as immune to memory exhaustion just because a logical device has been added. The useful achievement is conditional: suitable pages can occupy less physical room, allowing other useful work to remain possible within the available resources.
The decision to study zram can therefore begin with actual contents and access patterns rather than a search for a magic percentage. What data is retained? How well does it compress? How often is it recovered or rewritten? How much allocated memory is used, and what CPU work accompanies it? These are connected questions about one representation. They do not prescribe an administrative setup or require changing the machine that hosts this site. They explain why two people can report different experiences without either having discovered a universal rule for every workload’s memory behavior.
The stack of papers has not vanished. It has become a description that can be expanded again, and someone must keep that description somewhere. Zram makes the trade visible through a block device and through statistics that distinguish original information from its stored cost. The technology is most understandable when those statistics remain attached to their meanings. It can make better use of RAM for suitable contents without pretending to add physical chips. The useful question is what the machine can do with that changed representation, after the space saved and the work spent have both been accounted for.
Sources checked on October 22, 2026. The sizes are hypothetical; no zram device, swap arrangement, compression algorithm, or writeback setting was changed.



