List of Phobos functions that allocate memory?

Jonathan M Davis jmdavisProg at gmx.com
Fri Feb 7 11:53:11 PST 2014


On Friday, February 07, 2014 20:40:57 Dmitry Olshansky wrote:
> 07-Feb-2014 06:44, Walter Bright пишет:
> > On 2/6/2014 2:15 PM, Brad Anderson wrote:
> >> Personally I don't think bad user input qualifies as an exceptional
> >> case because
> >> it's expected to happen and the program is expected to handle it (and
> >> let the
> >> user know) when it does. That's just a matter of taste though.
> > 
> > It's not a matter of taste. If your input is subject to a DoS attack,
> > don't put exceptions in the control flow.
> 
> Meh. If exceptions are such a liability we'd better make them (much)
> faster.

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

The DOS aspect of exceptions are not something that I've ever thought about or 
seen discussed before, but one area where I've found the slowness of D's 
exceptions to be a real pain is in unit tests. I like to test failure cases as 
well as successful ones, and if you do much of that, your unit tests start 
taking a long time due to how insanely slow exceptions are in D.

So, while in some situations, the solution may be to not use exceptions (or to 
use them less), I think that we really need to look at doing what's necessary 
to make exceptions a lot faster - be it to more efficiently deal with stack 
traces or to avoid allocating them or whatever else we can come up with to 
make them fast. I think that the approach of assuming that exceptions don't 
need to be fast, because they're used for error conditions is a bad one. 
They're not as performance critical as normal code, but their speed still very 
much matters.

- Jonathan M Davis


More information about the Digitalmars-d mailing list