Difference between revisions of "Versus the garbage collector"
(initial) |
|||
Line 41: | Line 41: | ||
* Pro: Selective usage | * Pro: Selective usage | ||
* Contra: Attribute creep | * Contra: Attribute creep | ||
+ | |||
+ | === [http://forum.dlang.org/post/l33m84$kj3$1@digitalmars.com Implement Certain Interface] === | ||
+ | |||
+ | * Cannot find original thread | ||
== Links == | == Links == | ||
* http://forum.dlang.org/post/bsqqfmhgzntryyaqrtky@forum.dlang.org | * http://forum.dlang.org/post/bsqqfmhgzntryyaqrtky@forum.dlang.org |
Revision as of 16:39, 9 October 2013
The big discussion about the garbage collector repeatedly comes up. This page tries to provide a summary.
Contents
Why GC is bad
- Unpredictable pauses which stop the world
- Current implementation sucks
Why GC is good
- Safe by default and non-leaking memory management
- Acceptable performance for many cases
- Supports immutable types
Common Ground
- We want something, which is safe by default
Proposals
Compiler-supported Reference Counting
Compiler generates reference counting for all references
- Pro: More predictable
- Pro: No manual rewriting necessary
- Contra: Cycles would leak
- Contra: Overhead due to inc/dec operations
Library Reference Counting
Use std.typecons.RefCounted
- Pro: Garbage collector still provides safety
- Contra: Lots of manual work
- Contra: Overhead due to inc/dec operations
DIP18: nogc attribute
- Pro: Compile-time checked
- Pro: Selective usage
- Contra: Attribute creep
Implement Certain Interface
- Cannot find original thread