in reply to Re^3: Losing my memory
in thread Losing my memory
I wanted to post what eventually worked - a combination of several items put forward.
Creating the initial Photo image with no reference, then immediately loading the image from the file.
Adding a trap for catching the closure of the popup window ...# Start with a blank image - somehow this causes memory cleanup $TK{'image-'.$NVP{'Id'}}=$TK{'canvas-'.$NVP{'Id'}}->Photo(-file => + "" ); # Create an image object for the image file of the correct format $TK{'image-'.$NVP{'Id'}}=$TK{'canvas-'.$NVP{'Id'}}->Photo($NVP{'Id +'}, -file +=> $NVP{'File'}, -format +=> $image{'extension'});
And a subroutine to delete the images on the canvas as well as the images on exit ... using the magic delete -> delete(); thing# Create a "catch" for closing the window $TK{'pw-'.$NVP{'Id'}}->protocol('WM_DELETE_WINDOW' => [\&CleanUpOn +Exit, $NVP{'Id'}]);
It no longer chews up memory and even returns memory when the images are closed.sub CleanUpOnExit { # Get the id my $ID=shift(@_); # Delete images on the canvas $TK{'canvas-' . $ID}->delete("all"); # Delete the original image (delete $TK{'image-' . $ID})->delete(); # Destroy the popup window $TK{'pw-' . $ID}->destroy(); # Exit the Tk window Tk::exit; }
So I wanted to say thanks.
nzsvz9 - formerly known as the mad memory monger of my own creation
|
---|