ARSD PNG memory usage
thedeemon via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jun 16 19:55:43 PDT 2016
On Friday, 17 June 2016 at 01:51:41 UTC, Joerg Joergonson wrote:
> Hi, so, do you have any idea why when I load an image with
> png.d it takes a ton of memory?
I've bumped into this previously. It allocates a lot of temporary
arrays for decoded chunks of data, and I managed to reduce those
allocations a bit, here's the version I used:
http://stuff.thedeemon.com/png.d
(last changed Oct 2014, so may need some tweaks today)
But most of allocations are really caused by using std.zlib. This
thing creates tons of temporary arrays/slices and they are not
collected well by the GC. To deal with that I had to use GC
arenas for each PNG file I decode. This way all the junk created
during PNG decoding is eliminated completely after the decoding
ends. See gcarena module here:
https://bitbucket.org/infognition/dstuff
You may see Adam's PNG reader was really the source of motivation
for it. ;)
More information about the Digitalmars-d-learn
mailing list