in reply to Re: Images created in a loop grow
in thread Images created in a loop grow

I haven't used GD in years; is that better than declaring $im as lexical within the loop?

Replies are listed 'Best First'.
Re^3: Images created in a loop grow
by zentara (Cardinal) on Apr 16, 2006 at 16:54 UTC
    It would seem so. I can't say for sure, because I usually use Imager, or ImageMagick, but GD does act slightly different from most Perl objects because of it's c base. It actually runs well in a loop, and will not gain "program memory" if you undef it in the loop. I havn't tested it, but I would suspect that if you just rely on the lexical scoping, some of the previous GD object will get left for the the next run.

    Those Image modules are tricky. ImageMagick has a recipe too, it's

    undef @$image;
    which allows you to reuse the IM object, but flushes out all the old data.

    I'm not really a human, but I play one on earth. flash japh