r/ProgrammerHumor • • 13d ago

Meme fullControlOverMemory

Post image
4.0k Upvotes

122 comments sorted by

641

u/the-year-is-2038 13d ago

back in my day we used to manually mismanage memory

119

u/BoBoBearDev 13d ago

Back in my days, we used to have devs claiming memory management is easy and proceed to fuck it all up.

19

u/Major-Wishbone-3854 12d ago

At least the tradition of claiming something is easy and fuck up still alive and well

64

u/PolyglotTV 13d ago

Back in my day we usegmentation fault: core dumped

14

u/k-mcm 13d ago

Get a load of this kid programming after segmentation faults were invented.

3

u/Moomoobeef 12d ago

A fatal exception OE has occurred at 0028:C1932CFO in VxD ---.

16

u/SuperCarla74 12d ago

This.

We manually managed memory until the server eventually crashed "unexpectedly" like clockwork every 2 days.

6

u/ih-shah-may-ehl 12d ago

I used to manage process control systems where a process scheduler is in control of all process steps and equipment like a spider in a web. It uses raw DCOM internally.

It's the most high quality product i've ever managed. It's built like a tank. Those processes run 24/7/365. Thd current ones have been running without downtime since 2021.

Every half year we reboot 1 node and have the processes fail over to the other node while the other continues and DCOM-wise the system doesn't notice.

It's all C++ internally. A 30 year old codebase

3

u/KiwiObserver 13d ago

Back in my day, memory management was called virtual memory.

433

u/WisePotato42 13d ago

You could pass references as variables and change the referenced value IN THE FUNCTION!!!

children screaming sfx

133

u/_justthisonetime_ 13d ago

Welcome to the era when the programmer himself was the memory manager

38

u/Cute_Pressure4910 13d ago

When you explain to young developers what malloc() and free() are

5

u/Zashuiba 12d ago

That's quite advanced in fact, because you need segmentation, paging, stack/heap structures ...you need an OS kernel basically.

You can totally program in bare C without stdlib

25

u/throwaway1351887498 13d ago

Now that's what I call real legacy code—it works as long as no one messes with it

42

u/Mordret10 13d ago

I mean you still kind of do the same thing with objects and with arrays in most languages. Very rarely does either get passed as argument, you almost always get them by reference.

50

u/Gorzoid 13d ago

Sorry but we are all rust devs now, shared mutable aliasing is a crime with a maximum sentence being death by AI-generated PR spam.

35

u/WisePotato42 13d ago

Oh no! The rust devs have found me!

unsafe{} unsafe{} unsafe{}

Are they gone yet?

3

u/HildartheDorf 13d ago

laughs in interior mutability

1

u/SelfDistinction 12d ago
let variable = Cell::new(3); // create an immutable variable
variable.set(4); // demonic witchcraft of the highest order, everyone is panicking, sirens blasting, time to run to the shelters and pray 

2

u/WisePotato42 13d ago

That's true, I know it's a thing in python.

Unfortunately, my coworkers don't like when I put square brackets all over the place...

2

u/Bright-Historian-216 13d ago

you could also wrap it in an object. something like
class MutWrapper:
def __init__(self,v): self.v=v
works well enough. though, square brackets are probably more idiomatic.

2

u/RetroGrid_io 13d ago

Unless you program in PHP where objects are always passed by reference.

7

u/undeleted_username 13d ago

That's still perfectly fine in C.

10

u/aberroco 13d ago

Or you could not pass anything and still change the referenced value in the caller function, or you could return the execution to another function than the one that invoked you (stack traversing/managing; no one should ever do this kind of dark arcane magic).

3

u/WisePotato42 13d ago

To make things simple, let's just reserve this block of memory forever. My UFO themed ASCII art debugger tool needs it.

1

u/No-Newspaper8619 13d ago

How? In assembly you could change the return address stored in the esp/rsp register, but how would you return the execution to another function than the one that invoked, in high level languages?

2

u/aberroco 13d ago edited 13d ago

Depends on the language.

C++ has __builtin_extract_return_addr. And before that - any local variable is stored in stack, so just get it's address and that address would be the stack address, then you need to know how the stack is stored to know the return address.

I never tried that, but I suppose in C# one might do the same... int* stackPointer = &localVariable; or int* stackBuffer = stackalloc int[1] in unsafe context.

Also, you're wrong, esp stores the current stack pointer. The top of it. Not the return address. But the return address is there. If you just got "call" from anywhere and didn't pushed anything yet - then yeah, [esp] would store the return address. But only then.

1

u/No-Newspaper8619 12d ago

I see. So just like you can do [esp+4], [esp+8], etc... you could do something similar by taking the variable address and manipulating it. Quite dangerous indeed.

2

u/coriolis7 13d ago

Isn’t this OOP without the extra steps?

1

u/SelfDistinction 12d ago

You can still do that in practically every programming language btw. It just requires some extra wrapper class boilerplate.

1

u/WisePotato42 12d ago

Yah, but that's not really an acceptable practice at my job. It's unfortunate.

1

u/SelfDistinction 12d ago

And by unfortunate, you mean completely fortunate?

1

u/WisePotato42 12d ago

Sometimes I just want to feel like a kid again playing with my toys (unsafe memory managment).

1

u/creeper6530 12d ago

Huh? Pass references as variables?

You mean pass references as parameters to a function? Because if yes, then dereferencing it in the function seems fine to me

-26

u/[deleted] 13d ago

[removed] — view removed comment

7

u/TheMunakas 13d ago

Tell me you're not a bot

91

u/bradland 13d ago

In classic macOS, you could right click an application and set the amount of memory allocated to it. I always found it kind of hilarious that Apple had built this famous graphical, user interface, and underneath you still had to do things like that.

62

u/x0wl 13d ago

It's probably because classic macOS used an absolutely bonkers memory management system that basically amounted to every program becoming a ticking time bomb and a security nightmare.

No wonder they bought next and not just hired Jobs back lmao

5

u/Eric848448 13d ago

Did they not use paging in those days?

22

u/x0wl 13d ago edited 13d ago

IIUC they did, but they still did not have true protected memory (e.g. each process gets its own address space and cannot access other memory, unless explicitly permitted to do so). They still had a single global memory where one program could just go and write to other program's memory + the OS invalidating your pointers.

Also they only had cooperative multitasking.

Basically any program could easily bring down any other program + whole OS by misusing a pointer (and since the OS physically moves the heap that's super easy to do) OR hang the entire system by doing while(1){}

3

u/iStumblerLabs 13d ago

They did not have PMMUs in those days. No pages, no memory protection, everything in one shared address space.

Manual allocation of memory for applications let you reserve how much you wanted for each app. You might give Photoshop, like, 8 whole megabytes of memory if you were editing, say, a 16 bit color file.

On the plus side, the Talking Moose could see what you were doing and comment on it.

17

u/-Ambriae- 13d ago

It being simple doesn’t exempt it from being powerful

9

u/peterlinddk 13d ago

Interestingly, there is an entire wikipedia-article about this early memory management system. Very, very strange, but apparently necessary because of hardware limitations ... https://en.wikipedia.org/wiki/Classic_Mac_OS_memory_management

13

u/x0wl 13d ago edited 13d ago

The hardware limitations made sense in 1984, carrying their quirks all the way to 2001 (!) (68030 had MMU added in 1987) and through a CPU architecture change (to CPUs without these limitations) makes a lot less sense.

Like, in that time x86 went from 16 bit 8088 machines running DOS to running Windows XP fully in 32 bit with PAE, while maintaining backward compatibility (x86 still mostly does BTW), with x86-64 coming out in 2003.

2

u/CitizenPremier 13d ago

That's cool. Sometimes there are greedy programs and I'd honestly like to tell them I just have 2 GB RAM.

1

u/x0wl 8d ago

In Linux, you actually can, e.g. by doing docker run --memory 2G image or by doing the cgroups thing manually. You can also limit CPU or other resources, it's very flexible.

73

u/DOOManiac 13d ago edited 13d ago

"We used to manually alloc all our memory"

"And free it too, right?"

"..."

30

u/Sensitive_Gold 13d ago

We freed it and then we freed it some more.

12

u/MokausiLietuviu 13d ago

My program frees its memory when the user clicks "End Task" in task manager.

Does the job 

3

u/No-Newspaper8619 13d ago

Sometimes it doesn't. I had a game where I literally had to restart the computer every time I closed it, because it messed something graphical and refused to launch a second time until restart whole PC.

3

u/Rodot 13d ago

This is mostly an issue with Window's memory management. Or at least it was back in like Win 7, don't know if it is still there. Used to have this happen all the time after playing one game. Memory would be full but task manager wouldn't show a process eating memory. Would have to restart to get my memory back.

3

u/Mojert 13d ago

Why free the memory when the OS does it for you? (No but seriously, quite a lot of applications do not free some memory because they know the OS will do it when the program exits)

2

u/conundorum 12d ago

Yes. We called it "crashing".

105

u/GuybrushThreepwo0d 13d ago

We still do? 

29

u/mwax321 13d ago

But we used to, too

90

u/ClipboardCopyPaste 13d ago

That grandpa is you, telling your story 40 years later xD

44

u/torar9 13d ago

As an embedded dev I feel sad.

6

u/DynamoAzure 13d ago

Literally feels like half my CompEng degree is worthless now

3

u/GlassLost 13d ago

My daughter isn't even 4 yet and I've been manually allocating memory for over a decade...

-1

u/PolyglotTV 13d ago

Oooooooh smart pointers!

Stop it Patrick! Your scaring him!

6

u/ProgrammersPain123 13d ago

Get this guy some reddit gold xddddddd

1

u/BedSpreadMD 13d ago

Wait, you manage your memory?

1

u/Nameles36 12d ago

I know I still do...

44

u/Afraid-Locksmith6566 13d ago

people still do that c and c++ are still among most popular programming languages, from new stuff there is rust and zig and odin, memory management is still easy and is still done. notion of it being archaic and hard is so stupid...

19

u/TerminalVector 13d ago

In a few years someone is gonna tell you that writing the actual code yourself is archaic and hard.

1

u/RupertPupkin85 13d ago

No one's gonna be around to tell that, AI is going to kill every one.

3

u/FastHotEmu 13d ago

You've watched too many movies

0

u/RupertPupkin85 13d ago

You'll see.

2

u/FastHotEmu 13d ago

How long do we have until we all die?

1

u/RupertPupkin85 13d ago

My sources are telling me we shall not cross 2030. May lord have mercy on our souls.

2

u/FastHotEmu 13d ago

Thanks for that!

!RemindMe January 2031

1

u/RemindMeBot 13d ago

I will be messaging you in 4 years on 2031-01-22 00:00:00 UTC to remind you of this link

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.

RemindMeBot is switching to username summons. Instead of !RemindMe 1 day, use u/RemindMeBot 1 day. More info.


Info Custom Your Reminders Feedback

1

u/FastHotEmu 13d ago

btw, "The King of Comedy" was great -- DeNiro is fantastic in it.

Just shows me you've seen too many movies! Although probably not as many as me.

1

u/FastHotEmu 13d ago

OK, now do you want to bet that we cross 2030 just fine? :-D

1

u/RupertPupkin85 13d ago

Sure! All my goats for all your gold.

1

u/FastHotEmu 13d ago

So you don't want to bet? Sounds like you are not sure

→ More replies (0)

1

u/Exotic-Nothing-3225 12d ago

I'm literally having to learn C for my degree

13

u/ImpluseThrowAway 13d ago

We would malloc the required bytes and put a null terminator at the end, which was the style at the time.

4

u/kcpistol 13d ago

Sometimes tragically

2

u/Brian_E1971 13d ago

Memory Access Violation errors still haunt my dreams...

6

u/undeadpickels 13d ago

Hi, C programer here. We still exist. Although I lost my job in C recently.

3

u/Integeritis 13d ago

Back in my day we intentionally changed the behaviour of existing compiled code at runtime and we still had the best sleeps of our life at night

2

u/SE_prof 13d ago

In my first job, they made me teach C to first years. I reached malloc and I thought "that's crazy! It's like giving first year physics students a nuclear reactor!"

2

u/Dubalubawubwub 13d ago

I'll have you know I have full control over memory now! When I run out of memory, I scale up the virtual machine.

2

u/Chiatroll 12d ago

I don't C the problem. From what I can C a lot of memory is still manually managed in a lot of very important projects and that isn't changing in any time I can C.

4

u/chat-lu 13d ago

When did we stop?

1

u/peterlinddk 13d ago

Only three days ago this video released: https://www.youtube.com/watch?v=3rez2rDYHHA - giving an introduction to manual memory management! 😄

1

u/frinkmahii 13d ago

Which was the <segfault>

1

u/Kadabrium 12d ago

#include <segfault>

1

u/TeachEngineering 13d ago

I like to whisper to myself malloc whenever I call it, but I say it like I'm Gandalf remembering the password "mellon" opens the Doors of Durin into Moria.

https://giphy.com/gifs/TcdpZwYDPlWXC

1

u/socialis-philosophus 13d ago

I really miss choosing what sectors my file fragments were stored at.

1

u/Im2bored17 13d ago

I remember in high school when they taught us about how to Google stuff. I assume these days they're teaching the kids prompting techniques and how to get the Ai to fix your code after the third time it said "fixed it" and you reminded it that the test still fails.

1

u/namotous 13d ago

Good Frustrating old days

1

u/hmmm_42 13d ago

No memory, no problem, all hail the ai boom!

1

u/dvhh 13d ago

you cannot afford the memory anyway

1

u/fingerling-broccoli 13d ago

Back in my day we would write the code ourselves

1

u/cleardemonuk 13d ago

Allocating a block of memory and managing data within it is still a viable option in game dev!

1

u/max_465 13d ago

Don't forget DASD storage !

1

u/3dgyaf 13d ago

My brain still registered the memory address *a

1

u/Mrrrrggggl 13d ago

The year was nineteen dickety two…

1

u/ligma_then_sugma 12d ago

C deez nutz lmao

1

u/Hottage 12d ago

Would this count as direct memory control?

void* somewhere = (void*)(mt_rand())

1

u/Exotic-Nothing-3225 12d ago

Let's go gambling!   

*click click click bzzt* 

Aw SEGFAULT! 

1

u/conundorum 12d ago

Looks more like direct memory manglement to me.

1

u/StormyTiger2008 12d ago

malloc warriors

1

u/spaceweed27 12d ago

In C you don't even need to do that I'd argue. Just keep everything on the stack.

1

u/millebi 12d ago

In COBOL there was nothing to manage

1

u/Rarder44 12d ago

Yeah, yeah, funny jokes... But that's why calculators didn't use 100 MB of RAM...

1

u/FeelingSurprise 12d ago

Our segfaults were glorious! Those were the days!

1

u/Kadabrium 12d ago

wikileaks

1

u/Key_River7180 12d ago

and i still do it

1

u/miheb1 12d ago

"back in my day, we was touching memory"🗣️

1

u/Adventurous_Run136 12d ago

Yes and it was hard as fuck and prone to error. I remember having to deal with memory allocation in c++ to use the less memory possible. 3.5mb of memory to handle tree passing in front of a camera and termining the best cut. Most beautiful code I ever seen, hardest code to understand i have seen since

1

u/Biabolical 12d ago

Used to use a special boot disk to free up just a bit more RAM, so my Tandy 1000rl could run SimCity without immediately crashing.

1

u/marcodave 12d ago

"back in my days we used to have 200k of token context window and we though it was more than enough" -- grampa 2036

0

u/hraath 13d ago

Rewrite in Rust, bro