Garbage Collector for C++

Asked

Viewed 1,184 times

6

I clearly understand what a Garbage Collector is and what it is for. It is very well known in Java.

Is there a C++ library that implements GC or fixes memory lLeaks?

I’ve searched the internet but always results in C++ for Visual Studio, which is not useful to me.

1 answer

5


There is the C++/CLI from Microsoft. It is not the default C++ but uses the same GC in C#.

Some people consider that the proper use of smart pointers It is still a form of GC. Others think that this is not the case, although both manage the memory automatically. It is understandable that this form is a little more limited, but it works very well if you know what you are doing.

In addition, libraries can be used to help in this aspect. The newer versions of the standard C++ have been specifying ways to facilitate the development of more complex Gcs for optional use, but as far as I know there is nothing very good to use yet and it seems there won’t be, it’s one of those things that fell by the wayside. Today it is not easy to make a GC for C++, the language does not help.

There are conservative Gcs that help, but cause so much leakage that they become unviable in most cases. The best known is the Boehm.

If you do not know what you are doing even with GC there is memory leak, in any language. You have no idea how many applications have leaks and no one notices. It is usually noticeable only when the leak is very severe (common in C/C++) and when the application runs for a long time, which is uncommon in cases of other languages.

If you really think GC can help fundamentally, consider strongly using another language.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.