Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
October 14, 2012 [Issue 8820] New: Array initialization generates garbage | ||||
---|---|---|---|---|
| ||||
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@puremagic.com ReportedBy: malteskarupke@web.de --- Comment #0 from Malte Skarupke <malteskarupke@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: ------- |
October 14, 2012 [Issue 8820] Array initialization generates garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to Malte Skarupke | http://d.puremagic.com/issues/show_bug.cgi?id=8820 Jonathan M Davis <jmdavisProg@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |jmdavisProg@gmx.com Resolution| |DUPLICATE --- Comment #1 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-10-14 11:36:34 PDT --- *** This issue has been marked as a duplicate of issue 2356 *** -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 14, 2012 [Issue 8820] Array initialization generates garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to Malte Skarupke | http://d.puremagic.com/issues/show_bug.cgi?id=8820 --- Comment #2 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-10-14 11:40:17 PDT --- This is a long-standing, known issue. As a side note, it would be better to say that it allocates memory when it shouldn't rather than talking about generating garbage. That tends to imply that it generates garbage data (which it doesn't), giving the wrong impression about what you're talking about. All GC heap memory must naturally be garbage collected, so the issue is that it's allocated in the first place rather than the fact that it needs to be collected later. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 14, 2012 [Issue 8820] Array initialization generates garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to Malte Skarupke | http://d.puremagic.com/issues/show_bug.cgi?id=8820 --- Comment #3 from Malte Skarupke <malteskarupke@web.de> 2012-10-14 12:18:14 PDT --- (In reply to comment #2) > This is a long-standing, known issue. > > As a side note, it would be better to say that it allocates memory when it shouldn't rather than talking about generating garbage. That tends to imply that it generates garbage data (which it doesn't), giving the wrong impression about what you're talking about. All GC heap memory must naturally be garbage collected, so the issue is that it's allocated in the first place rather than the fact that it needs to be collected later. Ah sorry for not seeing the other issue. I searched for "array initialization", but didn't come across that one. And yeah, I can see there being issues with the double meaning of garbage in terms of the garbage collector and garbage in terms of garbage data. I'll use different terminology in the future. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
October 14, 2012 [Issue 8820] Array initialization generates garbage | ||||
---|---|---|---|---|
| ||||
Posted in reply to Malte Skarupke | http://d.puremagic.com/issues/show_bug.cgi?id=8820 --- Comment #4 from Jonathan M Davis <jmdavisProg@gmx.com> 2012-10-14 16:09:07 PDT --- > Ah sorry for not seeing the other issue. I searched for "array initialization", but didn't come across that one. Not a problem. It happens all the time. All it takes is someone wording things differently from how you think of the problem, and you won't find the issue. Just make sure that you put in a good faith effort to find an existing bug report before reporting it (as it sounds like you did). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation