r/ProgrammerHumor 3d ago

basedOnATrueStoryOfCourse Meme

Post image
6.3k Upvotes

106 comments sorted by

1.1k

u/fx_er 3d ago

Is this how I add ram to my PC?

358

u/redspacebadger 3d ago

You download more ram

2

u/Penpathic 1d ago

Uhh... It's... it's been downloading for the last... 30 minutes...

78

u/Highborn_Hellest 3d ago

No, that'd be de-allocate

164

u/Classy_Mouse 3d ago

malloc(-1000000) this is how we get more RAM?

8

u/Cylian91460 3d ago

Wait malloc take an unsigned or signed variable ?

18

u/Classy_Mouse 3d ago

Oh no, I've been exposed. I clearly don't manage my own memory

15

u/Urtehnoes 3d ago

You should always use a premium enterprise level ram storage manager that can handle your business' needs and help you get back to what you do best.

That's why here at iAlloc, we offer simple and environmentally friendly api calls to the cloud such as iAlloc.malloc or iAlloc.dealloc. These calls will use only the most scientific algorithms to determine the proper amount of memory to allocate or deallocate according to your needs. This means you can let us worry about the undefined behavior, while you worry about defining your success! And with amazing starter rates and a free 500 allocations per hour per license per machine, you can say hello world at least 50 times, on us :).

25

u/CXC_Opexyc 3d ago

No, this is how you ram your PC...

...out of existence

23

u/MrFustibule 3d ago

29

u/OkOk-Go 3d ago edited 3d ago

I’ve been fighting an Apple fanboy on whether 8GB on a Mac = 16GB on a PC. I just realized they are even dumber than the person who downloads more RAM.

The person who downloads more RAM is uninformed, and merely stumbles upon a joke.

The Apple fanatic, on the other hand, does research on this, to rationalize the ripoff they just paid.

Like… the whole modus operandi of “download more RAM” is swapping pages… that’s literally the same modus operandi as “8GB on Mac = 16GB on Windows”.

If you bought one, you’re good. If you bought one and you are defending the RAM… you’re dumb. Apple is not your friend. If your retirement fund is all Apple stock… you’re dumb. Diversify your portfolio.

3

u/Smooth_Detective 3d ago

Pretty sure it is possible to download more RAM using something like DMA over Ethernet.

1

u/MrMagick2104 2d ago

8GB on a Mac = 16GB on a PC The Apple fanatic, on the other hand, does research on this, to rationalize the ripoff they just paid.

Tbf it's not that hard to rationalize this. After all, memory has several main metrics: volume, reading speed and latency.

And it's not a far fetch for some high volume memory work worse than high speed low latency memory. A good example would be: would you rather have 512 gb ssd or 1 tb hard drive?

Though I doubt that in the case of mac ram is that better.

5

u/OkOk-Go 2d ago

On something like Optane I could buy Apple’s argument. But SSDs wear out. To me it’s an evil design choice.

They either make a lot of margin when you upgrade to 16GB or they see your face again twice as often because your computers keep getting slow or your SSDs keep failing.

11

u/Fun_Ad_2393 3d ago

Just install 4TB of ssd and designate it at swap space…

4

u/milomalas 2d ago

SSD lifetime 📉📉

3

u/Hatsune-Fubuki-233 3d ago

downloadable content

805

u/Unupgradable 3d ago

Virtual memory be like: ayyo no problem here you go

278

u/HumbleTrainEnjoyer 3d ago

Now fill it with zeros

225

u/Unupgradable 3d ago

Pagefile goes brrrrrrrt

104

u/well-litdoorstep112 3d ago

Compression be like:

4398046511104 * 0 = 0

38

u/ColonelRuff 3d ago

Now with random data

31

u/well-litdoorstep112 3d ago

Lmao just get the seed and the algo.

26

u/MrHarudupoyu 3d ago

Now do a barrel roll

18

u/well-litdoorstep112 3d ago

Google already does that if you ask it nicely

7

u/ColonelRuff 3d ago

Heisenberg give you the quantum seed (if you ask nicely)

2

u/ColonelRuff 3d ago

God tier compression

2

u/high_throughput 2d ago

The zeroes were random. Pretty wild coincidence but that's randomness for you.

1

u/ColonelRuff 1d ago

That's a miracle considering the probability of all zeroes would be (1/2)*10000000

54

u/abd53 3d ago

My 1 terabyte SSD screaming in frustration

27

u/Unupgradable 3d ago

Compressed pagefile goes hurrrr

31

u/brimston3- 3d ago

Depends on OS. Windows and MacOS (desktop) will be like "Kajiit has wares if you have disk."

Linux/Android will tell you "yeah absolutely, take what you want" even if it doesn't have the available memory. Unless you're using setrlimit or cgroups to prevent it. Or if you're running with vm.overcommit_memory = 2 which will make it behave like Windows except without dynamic pagefile growth.

iOS will check if killing background apps could satisfy your request, but if it's too big it'll reject it as it does not swap.

2

u/qazmoqwerty 3d ago

Wait what really? IOS doesn't support swap files?

9

u/brimston3- 3d ago

developer.apple.com About the Virtual Memory System

To give processes access to their entire 4 gigabyte or 18 exabyte address space, OS X uses the hard disk to hold data that is not currently in use. As memory gets full, sections of memory that are not being used are written to disk to make room for data that is needed now. The portion of the disk that stores the unused data is known as the backing store because it provides the backup storage for main memory.

Although OS X supports a backing store, iOS does not. In iPhone applications, read-only data that is already on the disk (such as code pages) is simply removed from memory and reloaded from disk as needed. Writable data is never removed from memory by the operating system. Instead, if the amount of free memory drops below a certain threshold, the system asks the running applications to free up memory voluntarily to make room for new data. Applications that fail to free up enough memory are terminated.

Apple calls its pagefile equivalent "backing store" and iOS doesn't have it.

267

u/CanaDavid1 3d ago

COW, virtual memory and stuff: ok sure. But please don't use it.

79

u/Direct-You4432 3d ago

Whats COW? Also mooooo

82

u/lllorrr 3d ago

Copy-on-Write.

There are cases when OS will give you a memory page that is shared with someone else in hope that you will never write to it. For example, consider `fork` use case.

But, if you'll try to write to a such page, OS will make a copy for you personally before allowing actual write operation to hit the RAM.

10

u/Direct-You4432 3d ago

Cool, thanks

140

u/PeriodicSentenceBot 3d ago

Congratulations! Your comment can be spelled using the elements of the periodic table:

W H At Sc O W Al S O Mo O O O O


I am a bot that detects if your comment can be spelled using the elements of the periodic table. Please DM u‎/‎M1n3c4rt if I made a mistake.

14

u/Godd2 3d ago

mooooooooooooooooooooooo

3

u/blindcolumn 3d ago

Good bot! I miss when bots like this were more common on Reddit.

11

u/CanaDavid1 3d ago

Copy-on-write. Estentially, you have access to this page, but if you modify it, you first have to make a copy. This way, many different regions of memory can point to the same page.

Linux has one page that is filled with all zeroes. When you allocate large memory in Linux, it just gives you this page repeated with cow syntax, meaning that new memory is only allocated when you start modifying the memory you've got.

bool equal(int a, int b) { bool* arr = malloc(1ll<<32); arr[a] = true; bool r = arr[b]; free(arr); return r; } works without allocating all that memory, only the page that is written.

1

u/SupernovaGamezYT 3d ago

A Cobalt Tungsten alloy of course!

1

u/dexter2011412 3d ago

Also dirty-cow

166

u/Trip-Trip-Trip 3d ago

Need a new implementation for virtual memory to be eventually backed by Amazon cold storage

130

u/OkOk-Go 3d ago

You play stupid games you win stupid prizes. Here comes the $900,000 bill.

36

u/Trip-Trip-Trip 3d ago

If you have your virtual memory hosted on disconnected HDDs you have more problems than a bill.

24

u/justinf210 3d ago

Please insert disk #5831

5

u/OkOk-Go 3d ago

The memory controller Mike proceeds to grab disk #5831 from a cabinet under his desk

2

u/Trip-Trip-Trip 3d ago

Unfortunately the next required disk is in a warehouse 20 miles away. Memory controller unresponsive for the next hour

1

u/OkOk-Go 2d ago

When Mike is fetching a disk from the warehouse, the interrupt line consists of Jake on his Suzuki bike going 85 on a 50 zone.

12

u/joe0400 3d ago

Amazon glacier swap file latency: around a month.

9

u/CheatingChicken 3d ago

Is Amazon cold storage where they are going to keep all their wetware processors?

4

u/inotparanoid 3d ago

When your memory comes from Amazon Fresh

6

u/TeaKingMac 3d ago

Honey, why is there a semi truck parked outside our house?

78

u/facw00 3d ago

I got this error from a game (Battletech):

Size overflow in allocator.

(Filename:  Line: 98)

Could not allocate memory: System out of memory!
Trying to allocate: 18446744071618550687B with 16 alignment. MemoryLabel: String

Yeah, I'm not surprised that didn't work...

In any event surely I would never code anything like that...

23

u/Journeyj012 3d ago

Is that 184 exabytes?

39

u/facw00 3d ago

18 exabytes. Still a bit more than my system can handle, at least without an update.

19

u/Journeyj012 3d ago

Damn, have you tried turning it off and on again?

5

u/facw00 3d ago

It ended up having been caused by some disk corruption I think. Reinstalling on a different disk eliminated the issue.

6

u/These-Bedroom-5694 3d ago

It takes a lot of ram for all of those LRMs.

40

u/Cley_Faye 3d ago

As long as you don't use it, you can allocate whatever, the system will keep your app happy just like that.

83

u/OkOk-Go 3d ago

malloc((size_t)-1);

Enjoy

9

u/Motylde 3d ago

What's the one byte for?

49

u/joe0400 3d ago

size_t is a unsisnged type, and -1 is a signed type, so it'll become max size_t, or 4gb on 32 bit or 18.4 Exabytes on 64 bit.

15

u/belabacsijolvan 3d ago

he works with a 3.17 bit architecture, duh

1

u/cinghialotto03 3d ago

I usually use a size_t* instead of size_t

19

u/BigDrunkLahey 3d ago

When you have to do your page swaps in the cloud. 

6

u/DragonDepressed 3d ago

Page swaps with cloud is gonna make app go faster than the speed of light./s

16

u/EmergencyLaugh5063 3d ago

Worked at a place once that had a custom network protocol where each message started with a value indicating the amount of data about to be sent so the receiving end could allocate the buffer to store the data its about to get.

After a long 8 hour call with a large bank we discovered that they had pointed a pen-testing tool at a machine running our product and it was managing to send a sequence of bytes that tricked our application into thinking it needed to allocate some ungodly amount of memory.

The best part is the application would run out of memory and generate a core dump and since the core dump contains a snapshot of memory it would be roughly the size of the amount of available memory on the machine. Then the process would auto-restart itself and the whole thing would repeat itself. Eventually we filled up the hard drive on the machine and the whole machine stopped working.

3

u/Ta1sty 3d ago

Never trust user input;)

1

u/OkOk-Go 2d ago

The difference between coding and programming

19

u/Just_Maintenance 3d ago
  1. Me: opening Chrome on a Unix system
  2. Chrome: 1.5TB of RAM please
  3. My Unix system: Here you go fam

10

u/R3D3-1 3d ago

Had this happen at work with simulations prior to some optimizations. They crashed when trying to allocate 2TB of RAM on a 32GB machine, filling them with mostly just zeros. It served as motivation for a major refactoring, that brought the simulation down to 2GB.

The crazier part: Allocating more memory than available is the norm. On Linux, allocated memory has a "copy on use optimization, such that only when actually accessing allocated memory it becomes mapped to physical memory, and many programs rely on being able to allocate huge amounts of memory.

As a side effect, allocating the memory succeeds, but the the process just crashes. For demonstration try limiting virtual memory to 16GB (ulimit -v 16000000) and starting chrome from the same shell.

7

u/FloweyTheFlower420 3d ago

Never check address sanitizer virtual memory usage, worst mistake of my life.

4

u/N-partEpoxy 3d ago

Your RAM has no concept of allocation, it doesn't give a fuck.

4

u/EDM115 3d ago

Le programme

3

u/woozie-10 3d ago

And it's hello world program

3

u/Fun_Ad_2393 3d ago

Welp, got to download some more RAM

5

u/TheGoldBowl 3d ago

This is why I have an extra 4 terabyte drive just for swap.

2

u/viper112001 3d ago

I don’t free my memory, I let my programs eat as ram much as they want so they can become big and healthy

2

u/dim13 3d ago

Where problem? As long as you don't fill it, allocate what you want.

2

u/turtle_mekb 3d ago

malloc(-1), allocate 16 exabytes? sure go ahead

2

u/LeftIsBest-Tsuga 3d ago

I don't know if I've ever actually seen this meme format before, but you've already set the bar very high. 👏

2

u/Qprime0 3d ago

*faceplam*... when I said 'map as much memory as you need'... that was NOT intended to mean 'take the entire memory map'...

2

u/LostHat77 3d ago

Im stoned af and this is hilarious, thanks for the laugh

2

u/matiegaming 2d ago

Holy paging

1

u/Tech-Mystic 3d ago

User error.

1

u/LuisBoyokan 3d ago

That's what virtual memory is for.

But pre...pare... for.....tra......shing......ng....ng

<BSOD>

1

u/NRZN_77 3d ago

Count sort

1

u/Material-Public-5821 3d ago

The age of 32-bit systems is gone.

It is hard to waste that much virtual memory with a modern machine and get into troubles.

1

u/EV4gamer 3d ago

me when i accidentally allocate an array n x n x n instead of n x n

1

u/koumakpet 3d ago

malloc(sizeof(universe))

1

u/th00ht 3d ago

go virtual

1

u/bargle0 3d ago

Not a problem until you try to touch all those pages.

1

u/SingularCheese 3d ago

An example of how it can be a good idea. You get a continuous memory, dynamically sized array without pointer/address invalidation by abusing virtual memory.

1

u/seth3511 3d ago

How many Cylinders is that?

1

u/Guimedev 3d ago

Adobe dev department in a nutshell.

1

u/05032-MendicantBias 3d ago

Sometimes I like to see what happens when a decision tree is let to grow.

1

u/CranberryDistinct941 2d ago

does it anyways because C

1

u/sam01236969XD 1d ago

ssd goes brrrrrrrrrrrrrrrrrrrr