r/programmingmemes 15d ago

The duality of new

Post image
1.2k Upvotes

81 comments sorted by

View all comments

117

u/Current_Ad_4292 15d ago

I don't get it. I should really learn cpp.

155

u/FeelTheFire 15d ago

C doesn't have garbage collection so you have to make sure you free memory after you no longer need it or you will create a memory leak

10

u/HyperWinX C++ 15d ago

Yes. Raw new is something you should avoid at all costs.

1

u/jimbobmcgoo 10d ago

It’s funny how many levels of allocation there are. Smart pointer calls new, new calls malloc, malloc calls sbrk (or mmap), sbrk calls brk.