Hacker news

  • Top
  • New
  • Past
  • Ask
  • Show
  • Jobs

Do not buy RAM, compress (https://curiousbits.nl)

292 points by Ecno92 about 24 hours ago | 235 comments | View on ycombinator

varenc about 16 hours ago |

As others have said, macOS does this by default and it's quite impressive. I have a long running daemon with a memory leak. By its nature, the leaking memory is very repetitive and easily compressed. Right now this daemon has tried to claim 2.5GB of memory, but it's been compressed to a mere 450MB of actual memory! And because it's a memory leak, it never accesses this old stuff, so it never gets decompressed. Only 20MB of RAM is held that isn't compressed.

Of course, it would be far better to just not have the memory leak...but in the mean time, macOS memory compression is making the leak nearly a none issue.

Lio about 22 hours ago |

RAM compression sounds very useful but the thing I really need extra RAM for is local inference.

Since the models are effectively highly compressed data already my assumption is that RAM compression won't help improve that much (I'm assuming unified memory here as per the Framework Desktop). A bit like trying to compress a JPEG in a zip file.

Could anyone comment on that?

hedgehog about 16 hours ago |

As others have noted zswap is usually a better choice than zram, additionally depending on your situation it may be worth checking which algorithm it's using as there are a few choices (zstd, lz4, etc) and the defaults vary by distro. zstd is the right choice IMO unless you're in a situation where you know better.

jakozaur about 21 hours ago |

> Memory compression is not new. If you have a Windows or Mac device you are already using it.

Yes, macOS has had it enabled by default since OS X Mavericks 10.9, released in October 2013. I’m surprised some desktop Linux distributions still require manual configuration to enable it.

For browser tabs, though, I think a better solution is automatic tab closing, using something like the Tab Wrangler extension for Chrome. Collecting tabs comes naturally; we’re much worse at closing them.

cogman10 about 17 hours ago |

Don't use Zram, use Zswap. Especially if you want to swap to disk.

https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-...

flowerlad about 15 hours ago |

In the 1990s there was a third-party add-on for Windows called SoftRAM95 [1] that doubled your RAM using compression. That one turned out to be a scam though [2].

[1] https://en.wikipedia.org/wiki/SoftRAM

[2] https://devblogs.microsoft.com/oldnewthing/20211111-00/?p=10...

sammatilda about 22 hours ago |

I just discovered zram thanks to claude after installing fedora on a new computer and man I was blown away by both zram and fedora. Fedora amongst the linux distributions for some reasons has really got everything that an end user needs and the whole experience is just way smoother than anything I have used in 25 years on linux.

I am hoping to switch my dad from ubuntu to fedora in a month or so because he has 16 GB ram and this seems like something most people dont know.

nukanse about 21 hours ago |

For a programmer, on many cases, it pays to compress the data, to improve RAM IO, because the alu may already be doing nothing meanwhile waiting for the data from ram, so you can use that time to decompress, process, compress, and store the result. A lot of code today is bottlenecked by IO. You spend a lot of effort optimizing with SIMD, processing the data super fast, and then the speed it's wssted because there is not enough bandwidth to even send the result to ram. Modern cpu should include more hardware support for memory compression

Waterluvian about 7 hours ago |

I have fond memories of being 8 or 9 and turning on RAM Doubler so that some of my Macintosh games would actually run. They were sluggish but they at least started.

Juvination about 17 hours ago |

What a fun loop through time. I remember downloading programs to free up ram in the early 2000's, then as RAM became more ubiqutous and programs were still small you could run them directly on RAMDisk. (I did this with Path of Exile about 10 years ago to avoid lag.) Now we are working back to getting the most out of our ram.

roosgit about 23 hours ago |

MacOS has been doing this for quite a while now. I was a bit surprised this wasn’t the default for most Linux distros, although I think Pop!_OS (what a name!) has had zram enabled for a few years already. I turned it on on one of my servers (1GB RAM) and it works fine.

certyfreak about 21 hours ago |

I switched to Fedora some time ago and only recently learned about zram. I was hitting full system memory(16GB) during normal use, and after increasing my zram to 16GB, I was blown away. I had initially planned to buy additional ram.

noodlesUK about 13 hours ago |

I think it's a great shame that kubernetes really doesn't like systems with any kind of swap on (including zswap). If memory compression were more commonly used I think many workloads could survive on smaller systems.

jmakov about 13 hours ago |

Looking at the solution AMD bought, looks like Linux has a lot of room to improve regarding moving (compressed) inactive pages to disk: https://www.amd.com/en/products/software/mext.html.

If my understanding is correct, both ZRAM and ZSWAP write uncompressed pages to disk. And both don't pack the pages together meaning even if we'd write compressed pages (let's say they compress 5:1), we'd still write the original size to disk. This is crazy.

trelliumD about 9 hours ago |

cyh555 about 3 hours ago |

Only if you use SSD because the operation involve will read from disks as well, not just decompressing the compressed RAM. It's very slow on HDD

myrandomcomment about 17 hours ago |

MacOS does this by default for inactive pages. On my current system with 18GB of RAM I show 4.80GB for Apps, 3.16GB Wired and 5.06GB Compressed.

aktenlage about 20 hours ago |

So, if it is used as swap, that means to use the data, it first needs to go to the CPU, then back to regular RAM, then back to the CPU.

Isn't that wasteful? The CPU's caches may help a bit, but I would guess first a huge block is going through the decompression, so only the last bits are still in the cache, when the actual usage starts.

Lerc about 17 hours ago |

I have to wonder if the better solution would be for browsers (and apps that are effectively broswers) to compress their data proactively.

I find that the ratio of browserish memory use to that of other programs is enough to render the latter insignificant most of the time.

rustyhancock about 21 hours ago |

I've used zswap on most of my systems and generally find it beneficial especially as (de)compression can be very fast these days.

What's interesting to note is that I've occasionally wondered why isn't the swap partition compressed.

If you have it on an NVMe drive it probably is as is all data! The controller usually transparently does it as it writes to/from NAND.

So the kernel sees uncompressed fixed block pages and the speed boosts happen with data arriving faster when read or written to flash.

2001zhaozhao about 12 hours ago |

I do this and also buy old used 16GB Optane sticks to use as swap. These are $7 a pop on ebay. They're way lower latency than normal swap and you can swap data as much as you like without worrying about wear.

manbash about 5 hours ago |

We've gone full circle. We kept swap partitions to minimal because RAM kept getting bigger and affordable. Now we're back.

zamalek about 13 hours ago |

> Compressing memory does come with small, but not really noticeable, downsides. It takes a little bit more from your CPU and adds latency to some processes.

I recall reading an article around the time the Windows team added it (back when I still used the OS). Their compression algorithm was typically faster than the latency to the prevailing disk type at the time (SATA SSD, most likely) - at the time it had zero downsides. I'm not sure if that still holds true.

On Linux it generally doesn't: off-the-shelf compression is used, which do not outpace storage access latency.

altcognito about 16 hours ago |

It's funny that MS didn't integrate memory compression until 2015. From ye olden days, we used "RAM doublers" in MSDOS, which were a bit of a different beast and took a performance hit due to simpler implementation, so some of us aren't "excited" by the cost of packing things in with compression. It is a bandaid for processes that lie somewhere between being needed and not (otherwise it would goto swap right?)

If it avoids hitting the disk I get it, but to some of us, that just means it's time to buy more RAM

72deluxe about 19 hours ago |

Having viewed that page, I cannot fathom how Firefox is using 27GB of RAM in his screenshot?!

Gehinnn about 9 hours ago |

Waiting for the day that an OS ships an LLM to optimize instructions globally, compresses RAM even smarter and fixes bugs/leaks on the fly.

pyaamb about 16 hours ago |

I wonder what the theoretical limits are of semantic compression for LLM input/output (eg. "Can you please send me the final report by Friday?" -> "Send final report by Friday." -> sr(FINAL, DEADLINE=FRIDAY)) that can still be recovered back to English

angst about 6 hours ago |

for Windows run (Get-MMAgent).MemoryCompression in Windows PowerShell (needs admin rights). It's usually True, but you can run Enable-MMAgent -MemoryCompression if not.

Ecno92 about 24 hours ago |

Since I am using Claude with parallel sessions in different workspaces I started to run out of RAM.

Instead of buying more RAM, which meant that I should replace my device, I decided to implement zram. This compresses memory. Now I can do more with the same hardware.

In many cloud environments compression is not enabled. I am curious to see if the same gains can be made in such environment.

IronWolve about 16 hours ago |

I remember the compression rage back on my amiga, had both ram and file compression, since you had to get as much room as you could with limited ram and a floppy.

grandlimelabs about 15 hours ago |

Make sure to stress-test compression and decompression for whatever you're doing before you go jumping into relying on it, though.

baud9600 about 21 hours ago |

You’d hope with these amazing GPUs today, that some cycles can be used to compress RAM very efficiently. So many parallel cores, surely we can get even better compression from this latent hardware?

bullish-bearr about 12 hours ago |

Doesn't this only work if you have a bunch of stuff you do not need to access frequently in RAM? i wonder what kind of algorithm optimization goes behind the scenes to make sure pages that least recently used get compressed with other pages

po1nt about 10 hours ago |

How did we allow websites to get this big anyway is beyond me.

ChrisRR about 22 hours ago |

> Compressing memory does not come with downsides. It takes a little bit more from your CPU and adds latency to some processes

It sounds like those are downsides

djha-skin about 12 hours ago |

This guy already had 32GB RAM. I know that's "standard" or whatever but it's surprisingly difficult to afford when you already have an 8GB laptop at home that still works on Linux. Would be interesting to see someone trick out a low-powered 4GB one, I would find that very interesting.

kiicia about 21 hours ago |

nice try Ram Altman

larodi about 11 hours ago |

Whatever could've been compressed reasonably by the open models, was already done by quantization, and guys sure know how to crunch data while it still matters.

yummybear about 22 hours ago |

"Compressing memory does not come with downsides. It takes a little bit more from your CPU and adds latency to some processes"

Which one is it?

vjvjvjvjghv about 13 hours ago |

Looks like I need to find my old SoftRAM floppy disk. Maybe somebody can come up with something that saves memory that's not used much to disk?

distantsounds about 17 hours ago |

Hilarious ending to the article. You expect some implementation details with a Getting Started section, instead you get a "check the arch wiki" link.

1970-01-01 about 15 hours ago |

This feels like the kind of thing that leads to 0day. Compression can defeat security. Delta frames. Compression bombs.

https://www.youtube.com/watch?v=4icQwducz68

https://www.youtube.com/watch?v=IXkX2ojrKZQ

lorenzohess about 6 hours ago |

What about downloading RAM?

claytongulick about 6 hours ago |

This made me think of the mid 90's and a friend of mine named Scott who was one of the smartest guys I'd ever met.

As a teenager, a company called Stacker that made a "RAM doubler" for DOS hired him to write their compression algorithms.

Hearing him talk, I felt like he was some sort of wizard - I wanted to be in that club.

He inspired a 30 year career in software development.

bismanawaz about 15 hours ago |

I was wondering if its the agents itself or the browsers that they open fill up the RAM?

1023bytes about 16 hours ago |

Do not buy RAM, download more RAM

tooheavy about 17 hours ago |

Compression is fine as long as the CPU doesn't become the bottleneck.

anizan about 11 hours ago |

Here we go with the softram remix

anizan about 11 hours ago |

Here we go with softram remix

fernandogrd about 17 hours ago |

Things I did: - Zswap instead of zram. - Unload browser tabs (my own private extension. - Force idle cli AI agents to go to disk swap earlier.

fred_is_fred about 17 hours ago |

pshirshov about 17 hours ago |

Vectors do not compress.

cubefox about 21 hours ago |

So why is zswap (basically zram+swap) not enabled by default everywhere?

tonymet about 13 hours ago |

I was load testing micro VMs with zswap and i was blown away by how much capacity the machine could have. forking thousands of processes, using 2.5x the available ram, and the server still hums along, albeit a bit sluggish. but no timeouts or lockups. still very accessible.

It's a remarkable tech that deserves more attention. Swap is back in style!

UltraSane about 16 hours ago |

IBM Power systems have hardware RAM compression.

undefined about 21 hours ago |

undefined

LoganDark about 21 hours ago |

Windows doesn't do memory compression if the page file is not enabled. I never particularly saw the point of the page file because I don't enjoy swapping, but it appears that the memory management system disproportionately depends on it to the point where it simply refuses to work properly with it off. So make sure that's turned on if you want memory compression. (Do not let it auto-size or it will happily fill up your whole drive, set it to something reasonable)

dmitrygr about 10 hours ago |

macOS has been doing this a while and this is the root of why users report 8GB macs easily handle more applications than 8GB Windows boxen. Since quite a long time ago, apple silicon even has hardware for this. Literally cpu instructions that do ram compression: https://asahilinux.org/docs/hw/cpu/apple-instructions/

dist-epoch about 21 hours ago |

> If you have a Windows or Mac device you are already using it

Technically yes, practically on Windows memory compression is not used.

I have Windows 11, 128 GB RAM, and my memory stats show: 42 GB in use, 380 MB compressed.

jauntywundrkind about 21 hours ago |

In many systems, adding compression makes not just storage better but increases the io you get from a system too. Here's Valkey 9.2 compression figures showing that: https://www.phoronix.com/news/Valkey-9.2

That's for RDB persistence. https://valkey.io/topics/persistence/

I wonder if there's any similar wins with ram? That some workloads would see net wins from compression. Some cost of cpu, but increasing net throughput significantly.

hinkley about 21 hours ago |

Okay, Johnny Mnemonic.

varispeed about 15 hours ago |

Do not eat, drink water.

As usual, working class is being told to tighten the belts whilst the rich get insanely richer.

Fuck that.

DeathArrow about 21 hours ago |

I have built my PC with core i7 14700K, RTX 3090,128 GB DDR3, 2TB SSD, 8TB HDD about 3 years ago.

Still perfectly usable and I won't upgrade until prices come down. Even used prices are terrible now.

mzhaase about 22 hours ago |

Zram vs Zswap: https://chrisdown.name/2026/03/24/zswap-vs-zram-when-to-use-...

> If in doubt, prefer to use zswap. Only use zram if you have a highly specific reason to.

> In terms of architecture:

> zswap sits in front of your disk swap, compresses pages in RAM, and automatically tiers cold data to disk. It integrates directly with the kernel's memory management and distributes pressure gracefully.

> zram is a compressed RAM block device with a hard capacity limit. When you put swap on it and it fills up, there is no automatic eviction, and the kernel has very little leverage to do anything about the situation. The system either OOMs or falls back to lower-priority swap, causing LRU inversion (see below). It only really makes sense for extremely memory-constrained embedded systems, diskless setups, or cases with specific security requirements around keeping private data off persistent storage. Swap on zram is also increasingly unsupported upstream.

ejazarain about 20 hours ago |

[flagged]

messe about 22 hours ago |

VCFundedGenYer about 18 hours ago |

[dead]