How to release Bitmap objet's from memory

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Funky
    New Member
    • Mar 2008
    • 13

    How to release Bitmap objet's from memory

    Hello!

    In my C# app I create an instance of the Bitmap class:
    Code:
    Bitmap img = new Bitmap(file); // file is a string that represents the full path of the image
    The image with the path stored in file variable could be deleted when I close the appliaction that is using that file in the instance of the Bitmap class. How can I release the image from the img variable so it wouldn't be used by the app anymore?

    Regards.
  • Funky
    New Member
    • Mar 2008
    • 13

    #2
    I just find out. I add the bitmap to the PictureBox. When I don't want to use the picture in my app anymore, I call the Dispose() method on the Image object represented by PictureBox;

    Code:
    pictureBox_odtis.Image.Dispose(); // pictureBox_odtis is an instance of the PictureBox class
    Regards!

    Comment

    Working...