[Issue 8820] New: Array initialization generates garbage
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 14 11:23:58 PDT 2012
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: nobody at puremagic.com
ReportedBy: malteskarupke at web.de
--- Comment #0 from Malte Skarupke <malteskarupke at 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: -------
More information about the Digitalmars-d-bugs
mailing list