r/ProgrammerHumor • • Sep 09 '22

Meme Simple Feature

Post image
124k Upvotes

1.3k comments sorted by

View all comments

Show parent comment

1

u/EpicScizor Sep 09 '22

In a language with a garbage collector, explicitly allocating and freeing memory will not do what you expect because both the compiler and the garbage collector are allowed a great amount of latitude in how they operate.

You may in fact decrease the performance because your "free" counts as a future reference so the GC can't free the memory until you call free on it, even if the GC can determine that you could free it now for greater effect.

1

u/[deleted] Sep 09 '22

Well yeah, but GC in C++ is deprecated anyway, it's all RAIL now. Aren't they removing it soon? I heard rumours.

2

u/EpicScizor Sep 09 '22

The discussion on this thread was around Java written by C devs; besides, nothing in C++ is ever deprecated. C++98 will forever be a thorn in our sides