News for hackers. Stuff that matters.
Re:Do not buy RAM, compress by jedbrooke on Thursday November 19, 2026 @04:52PM (#50566967)
I discovered something similar when I tried to recreate a rudimentary version of the Billion Laughs Attack[0] on my macbook. It just compressed all the “ha”s so the 10 GB string only ever took a few MB

0: https://learn.microsoft.com/en-us/archive/msdn-magazine/2009...

Re:Do not buy RAM, compress by razster on Thursday November 19, 2026 @07:41PM (#50568665)
But why? Curious as to the reason. Fascinating though.
Re:Do not buy RAM, compress by jedbrooke on Friday November 20, 2026 @12:25AM (#50570502)
oh hah, I’m not a security researcher or anything. I was just a high schooler messing around with computers. The rudimentary version I tried was just doing something like this in the python repl

    a = “ha”
    b = 10 * a
    c = 10 * b
and so on and watching the memory climb in the activity viewer. I was surprised when the 10GB or even 100GB one (confirmed with len() ) didnt crash my 8GB laptop or even cause it to swap.

Interestingly I tried the python version just now on modern macos, currently activity monitor shows 192GB ram used, 184GB compressed, on a machine with 36GB physical.

Actually something really weird happened, zsh killed the python proc, activity monitor shows it still alive, but the physical ram value is bugged and showing 0 bytes physical and 1.7 GB swap. So compressing RAM does have some limitations.

Re:Do not buy RAM, compress by AnthonBerg on Friday November 20, 2026 @02:05AM (#50571130)
haha!!
Re:Do not buy RAM, compress by varenc on Friday November 20, 2026 @02:30PM (#50580541)
I had a similar experience, but with Apple's APFS on-disk file compression! I accidentally generated a log file that just contains 300+ million lines of the same message repeated constantly. The log file was supposedly over 100GB in size, but I hadn't noticed my disk filling up. I investigate more, and discovered that APFS had compressed the file on my disk!

Apple's on-disk file compression is very mysterious, hard look up, and harder to intentionally trigger. The only clue in the Finder GUI is comparing the file size vs size on disk. Using the 3rd party `afsctool` you can tell APFS to compress a file on disk manually, but I believe there's no native macOS way to do this. The official way is that macOS decides for mysterious reasons when to compress a file on disk and it rarely does. But apparently generating a 100GB log file with million of repeated lines is enough to convince macOS to use APFS compression. (and having a disk that's nearly full probably)