Am 10.09.2012 21:54, schrieb Nick Sabalausky:

On Mon, 10 Sep 2012 21:37:49 +0200
Sönke Ludwig sludwig@rejectedsoftware.com wrote:

There were two or three places where memory was leaking. The current
master now uses malloc/free for almost all per-request allocations
instead of the GC. Memory usage on Windows now stayed absolutely
constant for 1.000.000 requests on my machine (about 10 MB virtual and
4,7 MB ram).

Nice!

I want to make the manual memory management optinal though because it
implies that no data of a HttpServerRequest must be stored outside of
the request handler function.

What about just passing the HttpServerRequest to the request handler as
a scope param? That way people can still do whatever they want with it,
but the compiler makes sure they properly dup anything they want an
escaping reference to. By contrast, a mem-leeky "HttpServerRequest that
can escape the request handler" doesn't sound like it would be
particularly useful to anyone.

The main problem is that every request handler then has to be augmented
with the scope modifier, which feels quite verbose. Also scope only
seems to have an effect on the object/variable itself and not on
anything that is contained in it, which is a real pity - might even call
it a bug. Both scope and unique could be extremely useful type traits,
but D is still lacking a bit there.

My current plan is to default to safe GC memory, which is reasonably
fast, and to provide the option to use the faster but unsafe manual
version when speed really matters. (I just tested the GC version and
its memory consumption is stable and only slightly worse with 11MB/5,8MB)