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


nfx...@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nfx...@gmail.com


--- Comment #1 from nfx...@gmail.com 2010-06-21 21:55:39 PDT ---
Congratulations, you just found out that D's GC implementation is fucking shit.
There doesn't seem to be a bug in std.file.read. It just uses the GC to
allocate a big chunk of memory, and returns it. There are probably false
pointers. Note that the latest allocated buffer will not be free'd with
fullCollect() (because you still have a reference to the buffer in that
variable), but I assume imageres.dll is much smaller than 200 MB.

Rule of thumb: never allocate big arrays with the GC.

There's a patch in bug 3463 to alleviate the problem, but it seems to be
abandoned.

Though, there is one potential problem in the D2 version of std.file.read. It
contains this line:

auto buf = GC.malloc(size, GC.BlkAttr.NO_SCAN)[0 .. size];

buf is returned as void[] to the user. As far as I understand the recently
introduced changes to array appending, the memory block for an array slice
contains a hidden length field. This is not present in this case, thus random
things may happen if you try to append to the returned array. I do not know if
this actually is a problem.

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

Reply via email to