I was having a serious problem with Tk::Animation because running a series of very large animated gif's (e.g., 100-900Kb) would eventually bog down the system. I presumed that memory references were not being dropped so the memory was accumulating. That was unacceptable for an application I am developing.

I decided that I had not really looked as closely at the Animation.pm file as I should have. Well, I looked at how the animated gif's multiple frames were being managed and discovered that they were being placed into an anonymous array in the object's 'self'-hash. I couldn't find any place where the references were being deleted.

So I added a function that pops the reference elements off the array and lets them simply die away. I was then able to open and close multiple animated gifs, far more than I was ever able to do with the previous version of Animation.pm.

Here is the function (it seems too simple):

sub del_frames { my $obj = shift; while( @{$obj->{'_frames_'}} ) { pop @{$obj->{'_frames_'}}; } }

In my application, I call del_frames after I stop using the animated gif and it is available and effective.

I hope that this may be useful to others. Tom


In reply to My fix for Tk::Animation by TomKane

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.