Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Tk and freeing memory

aspongeasponge Member Posts: 42
I'm Tk interface which loads in photos and displays them as thumbnail images. The problem I'm having is freeing the memory used from loading the original image. I want to get delete the original Photo object after I copy it to a to thumbnail. For example:

my $img = $main->Photo(
-format => "jpeg",
-file => "pic.jpg",
);

my $thumb = $main->Photo(-format => "jpeg");
$thumb->copy($img, -subsample => 16,16);

Now that I've got the thumb I want to get rid of the $img object. I've tried using $img->delete and $img->destroy, but neither of them actually free up the memory. I'm speculating that $main still holds a reference to the Photo object, but I don't know how to access that reference (if it does in fact exist).

If anyone has any ideas please let me know.
Kevin

Comments

  • bgibbybgibby Member Posts: 251
    : I'm Tk interface which loads in photos and displays them as thumbnail images. The problem I'm having is freeing the memory used from loading the original image. I want to get delete the original Photo object after I copy it to a to thumbnail. For example:
    :
    : my $img = $main->Photo(
    : -format => "jpeg",
    : -file => "pic.jpg",
    : );
    :
    : my $thumb = $main->Photo(-format => "jpeg");
    : $thumb->copy($img, -subsample => 16,16);
    :
    : Now that I've got the thumb I want to get rid of the $img object. I've tried using $img->delete and $img->destroy, but neither of them actually free up the memory. I'm speculating that $main still holds a reference to the Photo object, but I don't know how to access that reference (if it does in fact exist).
    :
    : If anyone has any ideas please let me know.
    : Kevin
    :

    Hi there,

    Yeah it seems that there is still a reference somewhere to your $img object. Maybe you could create a module to handle the images and just destroy those. This would guarantee it's destruction but require a bit extra code, esp. if your app is huge!

    HTH
    Bradley q:)
  • dalehenddalehend Member Posts: 33

    FWIW
    I believe in Perl6 garbage collection will be more accessible for dead objects..

    dale
    Moderator

    : Yeah it seems that there is still a reference somewhere to your $img object. Maybe you could create a module to handle the images and just destroy those. This would guarantee it's destruction but require a bit extra code, esp. if your app is huge!
    :
    : HTH
    : Bradley q:)
    :

  • ai.unitai.unit Member Posts: 81
    [b][red]This message was edited by ai.unit at 2003-6-5 15:48:31[/red][/b][hr]
    i know this is a too late reply, but i really wish to use a code similar to yours. i'm just a simple web designer, but unfortuantely i cant program in perl, and i need to resize an image using HTML like:
    image
    so please, someone help me if u can...

    many thx


    : I'm Tk interface which loads in photos and displays them as thumbnail images. The problem I'm having is freeing the memory used from loading the original image. I want to get delete the original Photo object after I copy it to a to thumbnail. For example:
    :
    : my $img = $main->Photo(
    : -format => "jpeg",
    : -file => "pic.jpg",
    : );
    :
    : my $thumb = $main->Photo(-format => "jpeg");
    : $thumb->copy($img, -subsample => 16,16);
    :
    : Now that I've got the thumb I want to get rid of the $img object. I've tried using $img->delete and $img->destroy, but neither of them actually free up the memory. I'm speculating that $main still holds a reference to the Photo object, but I don't know how to access that reference (if it does in fact exist).
    :
    : If anyone has any ideas please let me know.
    : Kevin
    :


    just a sam7 -/-



Sign In or Register to comment.