NotNull pointers

Jonathan M Davis jmdavisProg at gmx.com
Wed Aug 31 16:52:54 PDT 2011


On Wednesday, August 31, 2011 16:11 Timon Gehr wrote:
> On 09/01/2011 12:58 AM, Jonathan M Davis wrote:
> > On Wednesday, August 31, 2011 14:18 Steven Schveighoffer wrote:
> >> On Wed, 31 Aug 2011 16:54:50 -0400, Walter Bright
> >> 
> >> <newshound2 at digitalmars.com> wrote:
> >>> On 8/31/2011 1:19 PM, Steven Schveighoffer wrote:
> >>>> I think bloat can't possibly be a valid concern here.
> >>> 
> >>> You'd be surprised. I was surprised to discover that all the asserts in
> >>> std.datetime caused the unittest build of phobos to exceed all
> >>> available memory on my (old) FreeBSD box. (Jonathan used his own
> >>> version of assert that uses more runtime memory, he's got like 7500 in
> >>> there.) Minimizing the footprint of assert's reduces the resistance
> >>> people have to using them.
> >> 
> >> I think that:
> >> 
> >> 1. this is likely a combination of code generation issues in dmd and
> >> proliferation of asserts with templates/inlining as you say (I still
> >> feel there is something wrong with dmd, but I have no evidence).
> >> 2. Are more than 10% of those 7500 asserts of object references? I'd be
> >> surprised if that were true.
> > 
> > I don't think that there's even one assert on an object reference in
> > there (if nothing else, there are very few classes in std.datetime), and
> > none of them have invariants (some of the structs do but the few classes
> > have very little state). The issue with std.datetime is almost certainly
> > related to the number of templates (including _assertPred, which is
> > definitely templatized). Given the general proliferation of templates in
> > D (and Phobos in particular), dmd definitely needs to be efficient when
> > it comes to compiling templates, and that doesn't generally seem to be
> > the case with regards to memory consumption.
> 
> Probably that is because dmd leaks most memory it allocates. I seem to
> recall that is because of some bugs with interplay of the GC, which were
> resolved by just turning off the GC. What bugs were those?
> 
> I consider this an important issue, because I often cause the OS to swap
> heavily when compiling my Metaprogramming heavy code on my 2GB Ram
> machine, and I get one or two complete meltdowns each week.

LOL. The std.datetime unit tests have been disabled in Windows for some time 
now, because dmd ran out of memory compiling them. I think that it might be 
okay now, since the Windows makefile seems to have been changed so that 
modules are compiled and tested in blocks instead of just using one file, and 
various improvements have been made to CTFE and the like of late which should 
reduced memory consumption, but this is definitely a problem. As I understand 
it, with regards to CTFE at least, the compiler doesn't collect _any_ memory 
until it's done compiling (since the memory management is easier that way). I 
don't know if templates have the same problem or not. There are several bugs 
which have been reported on issues with dmd running out of memory. It doesn't 
appear to be a high priority issue though, since it hasn't been fixed yet. I 
do think that there were some recent improvements to it though (for instance, 
it used to be insanely easy to get startsWith to cause the compiler to run out 
of memory - since it's a recursive template - but that was supposedly fixed 
with the last release).

- Jonathan M Davis


More information about the Digitalmars-d mailing list