cpp-ru / ideas

Идеи по улучшению языка C++ для обсуждения
https://cpp-ru.github.io/proposals
Creative Commons Zero v1.0 Universal
89 stars 0 forks source link

Сборщик мусора #510

Open Andreyproger opened 2 years ago

Andreyproger commented 2 years ago

Сборщик мусора либо помечать участки не используемой памяти, чтобы избежать memory leak.

crackedmind commented 2 years ago

Было уже, с С++11 никто ничего не сделал, есть пропозал на удаление

Minimal support for Garbage Collection was added to C++0x in 2008 by [N2670]. The main addition was the concept of "strict pointer safety", as well as library support for this pointer safety. Most of the rationale leading to the wording in this paper is captured in the two preceding proposals that merged to form this minimal paper, [N2310] and [N2585].

There have been successful garbage collectors for C++, for example the Boehm GC as well as Garbage Collectors in language virtual machines where the VM is implemented in C++, to support a garbage-collected language. This allows the implementation language to reference objects in the garbage collected language, and lets them interface very closely. You’re likely reading this paper in such a virtual machine, implemented in C++, with support for garbage collection: JavaScript VMs do this. Similarly, you’ve probably played games which mix C++ and C# using the Unity game engine, which relies on the Boehm GC.

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2186r2.html

kelbon commented 2 years ago

Уже удалили поддержку, номинально добавленную в С++98

apolukhin commented 2 years ago

Посмотрите на Hazzard Pointer https://wg21.link/p1121

Это "правильный GC" для C++. Или вам нужно нечто другое?