in reply to Tk Image Flipping - Out of Memory

I've had trouble in general with objects not going out of scope in Tk. Create a DESTROY method and see if it ever goes out of scope.

I'm guessing Tk keeps refs to widgets around somewhere internally ?

Replies are listed 'Best First'.
(tye)Re: Tk Image Flipping - Out of Memory
by tye (Sage) on Feb 08, 2001 at 21:05 UTC

    I won't characterize this as (much) more than a wild guess, but I'll throw it out here anyway because sometimes that just motivates someone to correct me.

    Tk uses a lot of XS code and a lot of people that write XS code don't understand reference counting (especially when using "mortal" variables). If you make your reference counts too small, then things get free()d too soon and you notice. If you make your reference counts too big, then stuff hangs around forever and you don't notice unless you "go out of your way" to test for memory leaks (which you should do when writing XS code that creates Perl data items).

    So, anyway, back to the wild allegations. I suspect that Tk's XS code often sets reference counts too high which causes things to never be destroyed. I've certainly put in DESTROY methods and never gotten them to fire once Tk has a reference to that object.

            - tye (but my friends call me "Tye")