none
How to unload an image from the ImageList to save memory ? RRS feed

  • Question

  • I don't find any method to delete an image from the ImageList when we don't need it anymore.
    Is there a way to do that ? If no, can you add a UnloadImage to the ImageList for the next version ?


    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Saturday, April 25, 2009 9:33 AM

Answers

  • Fremy,  I was hoping that we wouldn't need to burden beginners with releasing memory.  It is a good thing to learn, but wasn't sure if they should get exposed at the start.  I'm happy to add, but would love to hear thoughts regarding this.
    Wednesday, September 16, 2009 3:35 PM
    Moderator

All replies

  • Hi, Fremy!  You're correct in that there is no way to delete an image outright from ImageList.  However, if you only intend to use the freed memory for another image, I believe it should be possible simply to "over-write" the first image with a different image source ( file, url, whatever... ).  For instance, the following code loads a small .gif image into a variable called "MyImage", displays it for approximately 1 second, then over-writes the "MyImage" variable with another .gif file, and displays that.  While I understand that this is not precisely what you're trying to accomplish, it may be an adequate work-around.  Hope this helps!

    MyImage = ImageList.LoadImage("C:\shot0.gif")
    GraphicsWindow.DrawImage(MyImage,1,1)
    Program.Delay(1000)
    GraphicsWindow.Clear()
    MyImage = ImageList.LoadImage("C:\shot01.gif")
    GraphicsWindow.DrawImage(MyImage,1,1)
    Wednesday, September 16, 2009 10:15 AM
  • Fremy,  I was hoping that we wouldn't need to burden beginners with releasing memory.  It is a good thing to learn, but wasn't sure if they should get exposed at the start.  I'm happy to add, but would love to hear thoughts regarding this.
    Wednesday, September 16, 2009 3:35 PM
    Moderator
  • Fremy,  I was hoping that we wouldn't need to burden beginners with releasing memory.  It is a good thing to learn, but wasn't sure if they should get exposed at the start.  I'm happy to add, but would love to hear thoughts regarding this.

    Adding the functionnality would not force the beginners to use. But I understand why you may wonder if you should implement it or not. Maybe it would not be so useful, as many SB applications are not very axed % performance. Maybe we should get another opinion about that to statuate.
    Fremy - Developer in VB.NET, C# and JScript ... - Feel free to try my extension
    Wednesday, September 16, 2009 6:22 PM
  • I doubt anyone would use the free feature, until they're at the point of moving on to more advanced languages and writing large programs.

    Wednesday, September 16, 2009 8:10 PM
  • Some good points on both sides of this issue.  It is sort of an advanced concept for beginners, but by the same token, why not learn good programming habits from the beginning? 
    Thursday, September 17, 2009 6:14 AM
  • An advanced feature with an accessible, simple explanation becomes a simple feature. I say include it, and make the description of it light.
    Wednesday, November 11, 2009 11:48 PM
  • isnt something like this possible? :


    MyImage = ImageList.LoadImage("C:\shot0.gif")

    MyImage = ""
    Live for nothing, OR CODE FOR SOMETHING!
    Saturday, November 21, 2009 3:22 PM