r/ProgrammerHumor • • Nov 03 '26

Meme seeSamAltmanImUsingMoreThan5PercentOfMyRAM

Post image
2.3k Upvotes

98 comments sorted by

1.0k

u/Dubmove Nov 03 '26 • Bravo

Did you reverse engineer chromium's source code?

235

u/PEAceDeath1425 Nov 03 '26

Is that the one that also had 100ms sleep instructions after every line

357

u/elmanoucko Nov 03 '26

-O3 optimizing it away: "I thought we were friends :'( ..."

162

u/PEAceDeath1425 Nov 03 '26

Optimizing? As a professional consumer, i can confidently say that word hasnt been said in IT since 2017 or smth

42

u/beloncode Nov 03 '26

Today is just: Claude pls, optimize my code. — the clause replies with: Sure, we just ripoff this feature and everything will gonna be faster

49

u/azurfall88 Nov 03 '26

just use volatile

56

u/med_bruh Nov 03 '26

The compiler trying to optimize your code then seeing "volatile" and "asm ("":::"memory")" in your code

65

u/Neutraled Nov 03 '26

I'm guessing Sam's house is full of clutter because he needs to use every inch of his house.

34

u/PEAceDeath1425 Nov 03 '26

My theory is that he works in uber, because leaving the house for work with 3 empty seats in a car is hella inefficient. Only 25% utilization

155

u/DangyDanger Nov 03 '26

system("pause") makes me irrationally angry

28

u/PEAceDeath1425 Nov 03 '26

Simplest way of keeping the app open and the RAM busy!!!

65

u/fynjy1111 Nov 03 '26 edited Nov 03 '26

while(true) sleep_for(std::chrono::milliseconds(500));

67

u/LegitimatePants Nov 03 '26

while(true); // tell him I'm using my CPU too

26

u/PEAceDeath1425 Nov 03 '26

Fucking brilliant, why didnt i come up with this? Now we only need to get the gpu working

12

u/Maniklas Nov 03 '26

Just add some code to get directx12 working for an hour or something, draw a circle over and over in the corner of the screen maybe

4

u/blockMath_2048 Nov 04 '26

just start a bunch of compute shaders with a while true loop

2

u/StaticCoder Nov 05 '26

3 words for you: "forward progress guarantee"

1

u/Deep-Piece3181 26d ago

Call yield in a spin

9

u/Cultural_Penalty Nov 03 '26

For me it's pow(2, 30) instead of 2 << 30, so...

17

u/Bth8 Nov 03 '26

2 << 30 is 2³¹

7

u/Cultural_Penalty Nov 03 '26

Right, but why not go big? Also, touch one byte every page. Just because.

3

u/Snudget Nov 05 '26

This is my favorite off-by-one, I keep making the same mistake

1

u/AFRIENDISNEAR Nov 03 '26

So inefficient 😭

61

u/GrandDukeNotaras Nov 03 '26

This meme wave just gets better and better. I'd give you some RAM if I could 

18

u/PEAceDeath1425 Nov 03 '26

i have 32 of them, dont worry! And with how shitty the webapps has been, i dont even have to launch my beautiful program half of the time. I stopped using Instagram on pc cause having it as a tab in Chrome legit eats 9GB of RAM, and thats just the worst i caught it eating

7

u/WithersChat Nov 03 '26

I develop Minecraft modpacks for fun in my free time.

At peak I need IntelliJ (java mod dev) + VSCodium (packside file editing) + 2 parallel Minecraft instances (some stuff requires that) + background music (for the lock-in) + discord (where my dev team is).
I wouldn't need your program either, even though it is beautiful.

6

u/GrandDukeNotaras Nov 03 '26

Some guy commented on another post that he has so much RAM that uses it as one would a HD

5

u/PostHasBeenWatched Nov 03 '26

With current RAMageddon the only thing we can do is RAMpage

P.S. **RAM page**file.sys he-he

1

u/CaesarOfYearXCIII 29d ago

But what about the RAMifications? You can’t just run RAMpant!

29

u/EatingSolidBricks Nov 03 '26

All mapped nothing commited you just got bamboozled by virtual memory

16

u/PEAceDeath1425 Nov 03 '26

Last time i did that with 32 instead of 30, it blue-screened my pc so uh theres that. Idk im a C++ larper i only studied it in uni

13

u/EatingSolidBricks Nov 03 '26

You're on windows then

14

u/PEAceDeath1425 Nov 03 '26

Correct, this is my personal gaming computer with way too much ram that would be better utilizied in s data center, 20 times better actually (5% vs 100% utilization)

2

u/RedAndBlack1832 Nov 05 '26

Ok that's funny af. I thought the os was meant to forcefully kill programs before they crash your computer by eating all the resources

2

u/PEAceDeath1425 Nov 05 '26

I remember blue-screening my old PC by simply having Chrome opened, listening to music and playing Satisfactory. It was 2021 and i had 8 gigs of DDR3 RAM.... Now i have 32 and i often forget to close one game before opening another and dont notice lol

2

u/A_72_ 29d ago

For me personally, 32GB still isn't enough because I may need 16GB RAM to play with FUSE a little bit (actually a Windows driver allowing FUSE), and I still need to both run the game and open chrominum based browser.

2

u/RedAndBlack1832 29d ago

Yeah 32 is soooo nice compared to 16 and 8 is like uhhhhhh gl with that

9

u/WeakCelery5000 Nov 03 '26

This is a trick, Sam wants you to burn out the ram you currently have, faster. 

15

u/PEAceDeath1425 Nov 03 '26

Dw im gonna download more if i lose this one

5

u/unneccry Nov 03 '26

Trust me i use all my 8GB of ram very frequently. Quite honestly i often use more

3

u/PEAceDeath1425 Nov 03 '26

You might be interested in increasing the power then to 31

2

u/OnixST Nov 04 '26

Yeah I think the 5% is quite insane. I know it's not that much off since we don't use our computers 24/7, but i definitely use my 16gb A LOT

I think it's probably true about vram though

3

u/Kadabrium Nov 03 '26

Does a ramjet leak ram

2

u/PEAceDeath1425 Nov 03 '26

No my ram is securely in my pc. Yknow i hope it doesnt leak, i have my gpu under it and im hoping to not get liquid on it.

5

u/beloncode Nov 03 '26

You aren't touching the ram, so the OS doesn't allocate it yet

7

u/PEAceDeath1425 Nov 03 '26

Sir, this isnt stack overflow

3

u/Tidemor Nov 03 '26

I know that's true for static memory, but thought heap does reserve the pages

2

u/intbeam Nov 03 '26

The operating system kernel will not assume intent on behalf of the application

I might be wrong, but my intuition says it would be weird and inefficient for the operating system to wait on allocation until the application commits a page. Without being a kernel expert, this sounds like the user mode application would need to communicate every read and write via the kernel just to check that the pages have actually been allocated, and then do that on-demand

For performance reasons, you don't want to cross the kernel barrier more than strictly necessary. Writing to virtual memory is hardware accelerated (exceptions apply), so as long as you have a valid page, the OS kernel don't need to be involved in normal reads and writes. If you read or write outside of that boundary, the CPU will raise a trap/exception that will be caught by the operating system which immediately terminates your application for being a bad boi indeed

Edit : if it does indeed not get allocated, I would assume that would be the doing of the allocator, rather than the operating system

2

u/beloncode Nov 03 '26 edited Nov 03 '26

Some syscalls like mmap in unix like system, you could pass a MAP_POPULATE and MAP_NORESERVE to predict this behavior in a new allocated memory block. malloc from glibc and musl doesn't populate the memory immediately. So we should expect some kernel trick here

2

u/intbeam Nov 03 '26

Hmm.. Ok, I see.. So, my assumption is that MAP_NORESERVE may introduce a performance penalty, since the next access would necessarily be a syscall. There might be a reason for this trade-off however, I could see that. And, again this is not my area of expertise, there might be some trick that I'm unaware of, like maybe the operating system has some user-mode space to jump to before system calls that keeps track of all virtual memory address as an added copy to the ring 0 configuration.. I have no idea. I'm riding on a hunch

I read some of the other comments, and they mentioned getting page faults which seems unlikely for the given scenario. At least, like a "real" page fault. My gut feeling is that the uninitialized pointer is, by the compiler, set to some predefined address and then the compiler+allocator looks at first access to a memory address by static analysis and then if that memory address asserted to be some predefined zombie-value at that point it would ask the operating system to allocate the memory address when it is needed. I only know this stuff at surface-level so I might be way off, but my thinking is that turning memset(a, 0, sizeof(char)*420) or a = {0} into a syscall would be prohibitively expensive. Experience tells me it's probably implemented in the most obvious and dumbest way possible, rather than some non-obvious trick

Edit : this is a question, though not formatted as such

2

u/beloncode Nov 03 '26

Hm, some virtual machines or emulators could use this (MAP_NORESERVE) for preallocate a address space at user space, and after, creates mirrors memory with a backing through a file descriptor. Like map the address 0x4000 virtual to 0x1000 physical inside this fd.

Also exists a PROT_NONE for remove any access to the pages, so any read inside this address space could rease a SIGSEGV, of course, if this memory isn't allocated and served by a real backing yet

2

u/intbeam Nov 03 '26 edited Nov 03 '26

I remain suspicious... So, let's say I have this code :

auto mydata = malloc(sizeof(size_t) * 4096 * 4096 * 4096 * 4096 * 4096);
dostuff(mydata);

void dostuff(const void* data)
{
    auto mptr = data;
    while(true) 
    {
         try
        {
            auto filteredbyte = *mptr++;
            gclient::Samsung::collect_byte(filteredbyte);
            gclient::LuckyGoldstar::collect_byte(filteredbyte);
        }
        catch
        {
            return; // we have it all
        }
    }
}

My assumption, would be that the compiler would statically assert that dostuff(mydata) attempts to access the memory, and at that point statically injects the allocation, rather than this being up to the operating system. Again, not an expert, I would just assume that lazy initialization would come at a tremendous cost.. There may be a trick here, but my naive assumption is that f.ex a syscall (being an interrupt, after all) would require context switching

Edit : jokes aside, I appreciate your input and knowledge. I'm surprised at how little I actually know about this. It's one of the things I've seem to have taken for granted

1

u/AFRIENDISNEAR Nov 03 '26

`malloc` keeps some heap space to avoid a syscall for small allocations. In this case, because the allocation is large, it won't even consider reusing some space, it will directly `mmap` some memory (a syscall that updates the process's address space in the kernel's records). This doesn't page-in the memory, so it isn't actually used yet. It is allocated page-by-page as needed. When a virtual address is accessed that doesn't have any physical page associated with it, the MMU triggers a page fault. This is an interrupt the operating system handles by checking the memory map of the current process, determining that this address is included in the process's address space (because of the previous `mmap`), and assigning a physical page to that virtual page in the MMU. Further accesses in the same page won't incur a fault, but this must be repeated the first time each page is accessed (or if a page is accessed that has been swapped out).

1

u/beloncode Nov 03 '26

In windows we don't even know, the kernel and user DLLs is closed so we can't have sure

8

u/EmperorOfAllCats Nov 03 '26

This won't be actually allocated by OS without, say, memset() on this range. Source: had to write similar utility to test memory pressure. 

2

u/GOKOP Nov 03 '26

OP is on Windows though (and claims that 32 gigs crashed his PC)

4

u/PEAceDeath1425 Nov 03 '26

It didnt at first, but it did after i reduced pagefile size to 512 mb

5

u/aaronlink127 Nov 03 '26

This is because "committed memory" still gets limited by Windows based on your physical RAM and pagefile limits, even if it never got any actual physical memory backing it.

5

u/No_External_4869 Nov 03 '26

Yeah pages aren't allocated till you try to interact with them. Interacting would trigger a page fault and then it will actually allocate a little (4KiB usually) if your data is below it. 

3

u/NotPossible1337 Nov 03 '26

But a memeset() can serve as a fallback, right?

29

u/farrell_987 Nov 03 '26 • Bravo

I'll sell Sam altman my unused ram as a service for 500/gb/hr

16

u/XVO668 Nov 03 '26

I miss the days where you could just simply download more RAM.

9

u/SerDuckOfPNW Nov 03 '26

Fewer memory leaks than a Bethesda game

15

u/sligor Nov 03 '26

Still less memory than any Electron app

1

u/Odd_Confusion_9875 Nov 03 '26

Does this work? Unless it's written on, pagefault doesn't trigger so physical ram won't be committed, Also it's just 8 Gigs.

mmap() with MAP_POPULATE might work through

3

u/PEAceDeath1425 Nov 03 '26

Does this work? Who cares, its a meme. It sends the message across in as little lines as possible

1

u/MooseBoys Nov 04 '26

Hey you never know - op could be compiling it to `BOOTX64.EFI`.

3

u/letmehaveanameyoudum Nov 04 '26

fool, i create a custom OS and fill the entire physical RAM with 1s

1

u/throwawayfu3a5ek Nov 03 '26

Back when I was doing c++ with pencil and paper in college, main had to return an int. I'm not sure if that has changed?

2

u/qalmakka Nov 04 '26

The standard says that if you don't return anything from main it's like as if you returned 0. Still it's bad practice and you'll go to hell. The reason is that main is a C concept and between non standard variants, old k&r shenanigans and such, there are a bajillion incorrect or nonstandard ways to write it

1

u/PEAceDeath1425 Nov 04 '26

Im making all my memes from hell. One visit to my page will prove that!

1

u/RedAndBlack1832 Nov 05 '26

int main(void); int main(int, char\*\*); int main(int, char\*\*, char\*\*);

Are all acceptable variations. int main() technically matches all of them, and other variations (often void main()) are accepted by some compilers

1

u/qalmakka Nov 05 '26

In C23, int main() becomes equivalent to int main(void) because they've finally removed the old "whatever parameters" meaning of ()

1

u/RedAndBlack1832 Nov 05 '26

That's good bc that was stupid and old and not recommended since forever lmao

2

u/VonLoewe Nov 04 '26

At least make it return, come on.

2

u/A_72_ Nov 04 '26

No, std::unreachable() and dive in undefined behavior monstrosity!

1

u/Right_Ear_2230 Nov 04 '26

It returns 0 automatically

1

u/DOOMer_3D Nov 03 '26

for(;;){(char*)malloc(4096)[0] = 'a';}

1

u/[deleted] Nov 03 '26

time to mcp my machine with this as the only tool call

1

u/compiling Nov 03 '26

Since you're on windows, you might be interested in a way to force the memory to stay allocated to your process instead of being paged out.

https://learn.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtuallock

1

u/A_72_ Nov 04 '26 edited Nov 04 '26

Have lots of ram? Init a ramfs and use it to store temporaries, 1GB ram = 1GB free storage! Leave enough for basic task only.

1

u/Single-Virus4935 Nov 04 '26

A system alwys uses the ram for disk cache. Postgresql for example factors the system cache in. So it is not uncommon to have a postgres server with 80% "free" ram.

1

u/Pesoen Nov 04 '26

don't even need something like this on my laptop 11gb used out of 15.3(707mb reserved)

main computer has no ram at the moment, but otherwise would have 32gb with about 15 used on idle(windows is a hog) jumps to about 18 when browsing the web

1

u/YakubReddit Nov 04 '26

you should put it in while (1)

1

u/TheSWATMonkey Nov 04 '26
void main(void){
    while(true)
        malloc(1024);
}

1

u/whtbrd 28d ago

He hasn't seen how many chrome tabs I have open.

1

u/bruhred 27d ago

linux overcommits memory so uhm this won't actually allocate everything

0

u/alonjit Nov 03 '26

the real horror is launching an executable when perfectly cromulent APIs exist.

-1

u/PEAceDeath1425 Nov 03 '26

Its the humor sub not the horror one

0

u/alonjit Nov 03 '26

well, it is certainly filled with horror stories lately. Must be the halloween ...

-6

u/equinoxtrader Nov 03 '26

Do you remember when this sub was with smart humor for smart people? We do remember.

4

u/PEAceDeath1425 Nov 03 '26

Sometimes the most effective punchline is a shortest one, even if it means sacrificing some accuracy

1

u/Yekyaa Nov 03 '26

Is this Euclidean space or Spherical space? Because you might need a less direct approach.

-1

u/deanominecraft Nov 03 '26

you can improve this by doing

let ram:Vec<u64>=Vec::with_capacity(2147483647);

-2

u/1XRobot Nov 03 '26

You can tell a human wrote this, because AI can spell.

Claude, write some code for my joke. Make several mistakes so it seems like a human.

1

u/PEAceDeath1425 Nov 03 '26

English is my third language.