http://d.puremagic.com/issues/show_bug.cgi?id=8820
Summary: Array initialization generates garbage Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: druntime AssignedTo: nob...@puremagic.com ReportedBy: malteskaru...@web.de --- Comment #0 from Malte Skarupke <malteskaru...@web.de> 2012-10-14 11:23:55 PDT --- Array initialization currently generates garbage that needs to be collected by the GC. { int[5] a = [1, 2, 3, 4, 5]; // generates garbage } { int[5] a; foreach (i; 0 .. 5) { a[i] = i + 1; } // same thing, but no garbage. everything is on the stack } Creating an array on the stack should be a trivial and fast operation. Yet stepping through the disassembly of that first line reveals a lot of overhead. But for now all I want fixed is that the first line does not generate garbage. The reason for why it generates garbage is that it allocates on the heap, then memcpys over to the stack, and never cleans up the memory on the heap. It should obviously initialize directly on the stack. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------