Garbage Collection for Systems Programmers

user1234 user1234 at 12.fr
Thu Apr 4 15:59:42 UTC 2024


On Thursday, 4 April 2024 at 15:42:24 UTC, ryuukk_ wrote:
> ```D
> import core.memory;
> import std.stdio;
> import std.conv;
> import std.datetime.stopwatch;
>
> string[int] stuff;
>
> void main()
> {
>     for (int i = 0; i < 10_000_000; i++)
>         stuff[i] = "hello_" ~ to!(string)(i);
>
>     auto sw = StopWatch(AutoStart.yes);
>     auto a = new ubyte[512_000_000];
>     writeln(sw.peek.total!"seconds");
> }
>
> ```
>
> Question to pro-GC crowd, why does it take 2 seconds to create 
> the array?

I'm not pro or con but that rather looks like a bug, i.e the 
new'ed array should not be scanned, it's not even initialized so 
in no way it can contain references to living-in-the-GC-pointers.

(side-node 3 secs here ^^).


More information about the Digitalmars-d mailing list