[Issue 9092] GC.extend allocates less then it reports

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 30 01:33:35 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=9092


Rainer Schuetze <r.sagitario at gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |r.sagitario at gmx.de
         Resolution|                            |INVALID


--- Comment #1 from Rainer Schuetze <r.sagitario at gmx.de> 2012-11-30 01:33:27 PST ---
I very much suspect that this is caused by the behaveour of large arrays that
need more space than 2048 bytes: these arrays store the actual allocated length
at the beginning of the block and reserve 16 bytes for that, in contrast to
smaller arrays that place this information at the end of the memory block (see
druntime/src/rt/lifetime.d for details).

So in your case, a.ptr does not point to the start of the memory block, but 16
bytes into it, leaving a little less than the actual memory size for the array.
GC.extend changes the memory block, but doesn't know about the array-semantics,
so it reports back the raw size of the memory block.

Your example mixes high level memory access (arrays) with low level functions
(GC.extend), I don't think that is a good idea. Instead, use GC.malloc for your
first allocation.

-- 
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