Welcome to This Week in D! Each week, we'll summarize what's been going on in the D community and write brief advice columns to help you get the most out of the D Programming Language.
The D Programming Language is a general purpose programming language that offers modern convenience, modeling power, and native efficiency with a familiar C-style syntax.
This Week in D has an RSS feed.
This Week in D is edited by Adam D. Ruppe. Contact me with any questions, comments, or contributions.
See more at the announce forum.
I did some minor changes to my png.d this week that caused a major reduction in memory usage: changing temporary allocations to reuse a manual buffer and free it when I'm done with it.
Another part was transitioning away from std.zlib and using the C interface, etc.c.zlib instead. std.zlib (which has been mentioned before in these tips) allocates a lot of temporaries without cleaning up after them.
Temporary allocations tend to be cleaned up eventually, but since they are local to your function, they are really easy to manage with a simple scope(exit) free(memory);, so the cost to the programmer is very low for the benefit.
png.d cut its memory usage down to about 1/3 of what it was with just a couple simple scoped lifetime memory frees.
To learn more about D and what's happening in D: