Garbage Collector
thedeemon
dlang at thedeemon.com
Sat Dec 1 04:46:13 PST 2012
On Friday, 30 November 2012 at 23:21:39 UTC, js.mdnq wrote:
> http://stackoverflow.com/questions/13574552/d-programming-without-the-garbage-collector
> and did some investigating of my own.
>
> I noticed that in both x64 and x86 builds the GC seems to get
> exponentially slower as the objects are allocated.
>
Your program should get quadratically slower.
If you just allocate in a loop, GC is called O(n) times and each
time it scans all the heap, each scan is O(n), so you get O(n^2)
overall time.
In some other languages' runtimes heap growth is adapting to
allocation rate, so there are fewer GC invocations. But anyway
this kind of loop will be slow in any GCed language unless you
allocate all available memory right away. In C/C++ there are no
calls to GC, so it works in O(n).
More information about the Digitalmars-d
mailing list