r/ProgrammerHumor • • Oct 10 '26

Meme theyAreLovingIt

Post image
2.1k Upvotes

83 comments sorted by

View all comments

25

u/nimrag_is_coming Oct 10 '26

Tbh memory management isn't that difficult if you're not stupid with it

13

u/ChillyFireball Oct 10 '26

Also worth noting that garbage collectors don't offer total immunity from memory leaks, and can even make people more careless because they don't expect to have to release anything. I've seen stuff crash because the service would save a local history of what it got from another endpoint, but the developers forgot to limit the amount of history saved, and no one noticed until it went to production because when you're programming, you're constantly refreshing/rebuilding the stuff you're working on, not leaving it running to see if it still works after four hours. I've also seen leaks from intervals and event handlers that get initialized when a component is mounted without any accompanying release mechanism when it's unmounted, so every time the component is toggled, a new event handler or interval is created without removing the old one.

8

u/bestjakeisbest Oct 10 '26

You allocated the variable, now unallocate it

3

u/static_func Oct 10 '26

It isn’t a matter of it being difficult, it’s a matter of being tedious and unnecessary for most work. Also if others in your company are stupid with it, it’s now your problem

3

u/nimrag_is_coming Oct 10 '26

True, although this is why things like modern c++ has RAII and means you (almost) never have to write new/delete. And smart pointers too

1

u/LordRaizer Oct 11 '26

Yeah

You got things like smart pointers and STL generics that handle it for you nowadays (and also dynamically resize as well)

But learning C++, you definitely should do it from scratch to know how it works and learn the best practices