332

Finally I have a valid reason to learn about memory management. It was also hella weird when encountering it.

you are viewing a single comment's thread
view the rest of the comments
[-] henfredemars@infosec.pub 2 points 7 months ago* (last edited 7 months ago)

You call the destructor. It’s simply not automatically done for you with the concept of going out of scope.

Back when C++ was simply a text pre-processor for C, you could see these normal function calls. You can still see them in the un-optimized disassembly. There’s nothing magical about a destructor other than it being inserted automatically.

[-] entwine@programming.dev 2 points 7 months ago

being inserted automatically.

Aka the entire point of RAII

[-] resipsaloquitur@lemmy.world 2 points 7 months ago

The point of RAII is that a resource is allocated and freed in the same scope.

You can free it with an explicit call to a destructor, an implicit call, or with memory allocated on the stack, just wait for the stack frame to be exited.

this post was submitted on 31 Aug 2025
332 points (96.4% liked)

Programmer Humor

30835 readers
1070 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS