4 ms·
garbage collector
by arte2k 13y ago
garbage collector
- k__ 13y agoso the GC isn't optional in D?
- arte2k 13y agonot as far as I know. while having garbage collection was an asset when java was created, currently with ubiquitous RAII usage in c++ it's just a hindrance.
- deleted 13y ago[deleted]
- eco 13y agoThe GC is optional in D (parts of the standard library use it so you'd have to avoid those). D uses RAII when it makes sense too.
- Pxtl 13y agoIt is, but the standard library uses it so you have to avoid them if you want no GC.
- CountHackulus 13y agoThat's changing. The standard library is almost entire GC-free now.
- he_the_great 13y agoThat's a little adventurous. std.algorithm is known to only have one function which allocates. The rest of Phobos is being looked at, but to this point I don't think it has been combed thoroughly enough to say "almost entire."
- jmdavisProg 13y agoYeah. The "almost entire" applies to std.algorithm. How much allocation goes on elsewhere depends on what module you're talking about. Some definitely avoid it, whereas others definitely require it. That will be (and has been) changing though. The main thing is probably going to be making much heavier use of output ranges rather than automatically allocating arrays/strings. We'll get there though, because there's clearly a lot of interest in doing so, and there's no fundamental reason why we can't.
- eco 13y agoI'm not sure where you got that idea but that's not true. The standard library make heavy usage of the GC. There is talk of implementing ARC to replace or supplement the GC and the standard library will most likely soon start using output ranges to avoid forced GC allocations in many cases but that hasn't happened yet.
- albertzeyer 13y agoFrom Wikipedia: "Memory is usually managed with garbage collection, but specific objects can be finalized immediately when they go out of scope. Explicit memory management is possible using the overloaded operators new and delete, and by simply calling C's malloc and free directly. Garbage collection can be controlled: programmers can add and exclude memory ranges from being observed by the collector, can disable and enable the collector and force a generational or a full collection cycle. The manual gives many examples of how to implement different highly optimized memory management schemes for when garbage collection is inadequate in a program." I wonder if the GC is stop-the-world.
- steveklabnik 13y agoFrom http://dlang.org/garbage.html http://dlang.org/garbage.html : > Stopping all other threads than the thread currently trying to allocate GC memory.
- pcwalton 13y agoIn D the garbage collector is stop-the-world and conservative, last I looked.
- qznc 13y agoThe D community has not found any good alternative yet. The wiki contains a summary: http://wiki.dlang.org/Versus_the_garbage_collector http://wiki.dlang.org/Versus_the_garbage_collector