I my view garbage collection and memory safety are two totally different things, maybe I'm wrong.abulmo2 wrote: ↑Tue Sep 15, 2020 2:27 pmThere is a lot of myths about garbage collection. Here is the relative time spent in the garbage collector (GC) in Amoeba (programmed in D):mvanthoor wrote: ↑Tue Sep 15, 2020 1:42 pmWith a garbage collected language such as C#, you're correct.Joost Buijs wrote: ↑Tue Sep 15, 2020 12:49 pm I have to admit that I don't know much about recent languages like D or Rust, if these languages offer default memory safety this must have some impact on performance, this is inevitable.All these sum to 0.00%.Code: Select all
0.00% amoeba amoeba [.] nothrow void* gc.impl.conservative.gc.Gcx.smallAlloc(ulong, ref ulong, uint, const(TypeInfo)) 0.00% amoeba amoeba [.] nothrow uint gc.impl.conservative.gc.ConservativeGC.runLocked!(gc.impl.conservative.gc.ConservativeGC.getAttr(void*).go(gc.impl.conservative.gc.Gcx*, void*), gc.impl.conservative.gc.otherTime, gc.impl.conservative.gc.numOthers, gc.impl.conservative.gc.Gcx*, void*).runLocked(ref gc.impl.conservative.gc.Gcx*, ref void*) 0.00% amoeba amoeba [.] nothrow void* gc.impl.conservative.gc.ConservativeGC.runLocked!(gc.impl.conservative.gc.ConservativeGC.mallocNoSync(ulong, uint, ref ulong, const(TypeInfo)), gc.impl.conservative.gc.mallocTime, gc.impl.conservative.gc.numMallocs, ulong, uint, ulong, const(TypeInfo)).runLocked(ref ulong, ref uint, ref ulong, ref const(TypeInfo)) 0.00% amoeba amoeba [.] nothrow uint gc.impl.conservative.gc.ConservativeGC.getAttr(void*).go(gc.impl.conservative.gc.Gcx*, void*) 0.00% amoeba amoeba [.] nothrow void gc.impl.conservative.gc.Pool.setBits(ulong, uint) 0.00% amoeba amoeba [.] nothrow int gc.impl.conservative.gc.Gcx.collectAllRoots(bool).__foreachbody3(ref core.gc.gcinterface.Range) 0.00% amoeba amoeba [.] nothrow void gc.impl.conservative.gc.Gcx.scanBackground()
Garbage is collected only when memory allocation is requested. In Amoeba, memory is allocated only during program initialisation and when reading input from the user/GUI, not in critical code section, so costs nothing measurable during the program execution.
My interpretation of garbage collection is freeing memory allocations that are not needed any longer, like artificially fixing a program that contains memory leaks.