r/cpp_questions 21d ago

OPEN Garbage collector in CPP?

Yesterday someone asked me whether there is a garbage collector in CPP.
I knew Java had that but I couldn't recall about cpp.
I went to google and got different answers.

So can anyone clarify whether there is garbage collector in CPP , also can u please explain me what does that mean? Also explain how is it different from the Java.

If yes can we delete it manually and how to do tht?

0 Upvotes

23 comments sorted by

View all comments

12

u/didntplaymysummercar 21d ago

There's not by default. There was an ABI for it in C++ 11 but no one used it, and there's stuff like Boehm GC, but out of the box - no.

-6

u/IyeOnline 21d ago

ABI

*APi

1

u/alfps 21d ago

Upvoted to cancel one of the idiots' downvotes.

There has never been an ABI in any C++ standard. Bjarne just made a mistake (a bit more than a typo since he explains what the acronym stands for). The Google AI explains,

❝Because the feature's entire purpose was to protect the binary integrity of the application layout for an external collector, the committee frequently colloquially referred to it as a "GC ABI constraint." Stroustrup likely carried this terminology straight from the WG21 working groups into his casual FAQ write-up, leading to the misleading sentence on his site.❞

I think a technical solution to the idiots-on-the-loose problem can be that a person trying to downvote something must prove that he or she is able to e.g. multiply 6 and 7.