Thread overview
[Issue 3112] New: Specification on what operations call the GC is missing
Jun 30, 2009
llucax@gmail.com
Nov 10, 2010
Walter Bright
Dec 22, 2010
Petr Janda
Dec 22, 2010
Jonathan M Davis
June 30, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3112

           Summary: Specification on what operations call the GC is
                    missing
           Product: D
           Version: 1.045
          Platform: Other
        OS/Version: All
            Status: NEW
          Keywords: spec
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: llucax@gmail.com
            Blocks: 677


There are several languages constructs that rely on the GC and use it, like array concatenation and appending. This operations are not properly documented.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 10, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3112


Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla@digitalmars.com
         Resolution|                            |FIXED


--- Comment #1 from Walter Bright <bugzilla@digitalmars.com> 2010-11-10 00:25:48 PST ---
http://www.dsource.org/projects/phobos/changeset/2153

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3112


Petr Janda <janda.petr@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |janda.petr@gmail.com


--- Comment #2 from Petr Janda <janda.petr@gmail.com> 2010-12-21 23:40:16 PST ---
Why are things such as array concat and appending relying on GC? It looks to me as that a lot of them could be accomplished without it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 22, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=3112


Jonathan M Davis <jmdavisProg@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jmdavisProg@gmx.com


--- Comment #3 from Jonathan M Davis <jmdavisProg@gmx.com> 2010-12-22 00:03:29 PST ---
They use the GC for two reasons of which I am aware:

1. They potentially have to reallocate. That means allocating memory which
normally means using the GC. And since there's no way to tell something like ~=
to use malloc() (and potentially free()) instead of the GC, it _has_ to use the
GC.

2. As I understand it, the GC does some sort of voodoo to determine whether an array actually has the capacity to increase its size in place. That's likely going to have to figure out whether _other_ arrays refer to the memory immediately after the end of the array, which would somehow involve looking at the other arrays, which would require the GC, since one malloc-ed item knows nothing about another malloc-ed item. The fact that you have slicing likely complicates things a fair bit.

It would probably be possible to do array concatenation and appending without the GC if arrays were not designed to use the GC (after all, vectors in C++ are able to reallocate without the GC), but since they _do_ use the GC, they have to use the GC for operations which would result in reallocating memory.

Actually, I believe that Steven pointed out on the list recently that you _can_ use appending with non-GCed dynamic arrays but that you have to maintain references to the original before you append so that you can free that memory if you need to. So, it _is_ possible, but it doesn't work very well.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------