Re: Cycling between images increases memory usage
From: Bob Powell [MVP] (bob_at__spamkiller_bobpowell.net)
Date: 05/09/04
- Next message: Aaron Queenan: "Re: How can I get the TreeNode from a System.Windows.Forms.Message message?"
- Previous message: Herfried K. Wagner [MVP]: "Re: Cycling between images increases memory usage"
- In reply to: Scytrax: "Re: Cycling between images increases memory usage"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Cycling between images increases memory usage"
- Messages sorted by: [ date ] [ thread ]
Date: Sun, 9 May 2004 13:23:50 +0200
Ahh, I see.
I will run a test myself to see what the effect is. Maybe PictureBox has a
leak. It's my least favourite control and the easiest to write a
replacement for so that's an option.
I'm glad you enjoy my site.
-- Bob Powell [MVP] Visual C#, System.Drawing Image transition effects, automatic persistent configuration and design time mouse operations all in April's issue of Well Formed http://www.bobpowell.net/wellformed.htm Answer those GDI+ questions with the GDI+ FAQ http://www.bobpowell.net/gdiplus_faq.htm The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml Bob's Blog: http://royo.is-a-geek.com/siteFeeder/GetFeed.aspx?FeedId=41 "Scytrax" <anonymous@discussions.microsoft.com> wrote in message news:9D27A085-BA98-4298-A711-20ED45AF0F25@microsoft.com... > Hi Bob. > > I read your faq recently and realized the importance of disposing images. That handled another problem I was having in the same application. Thanks. > > However, when cycling images in the picture box, I cannot dispose of the image because I keep looping through the images and so I need all images to be displayed more than once. > > I do something like the following (pseudo code): > > int counter = 0; > Image images[] = new Image[5]; > images[0] = Image.FromFile("image1"); > images[1] = Image.FromFile("image1"); > images[2] = Image.FromFile("image1"); > images[3] = Image.FromFile("image1"); > images[4] = Image.FromFile("image1"); > this.Timer1.Start(); > > onTimerTick: > > this.PictureBox1.Image = this.images[counter++]; > if(counter == this.images.Length)counter = 0; > > In theory, this should not cause any memory problems, right? > > I have been testing my program again during the night and after running app. 6 hours, I only had an increase of about 200K. So maybe I don't have a problem anymore. However, I would still like a confirmation that the general procedure as described above should not cause any memory problems. > > Thanks for being a great help to your fellow coders, Bob! > > Anders
- Next message: Aaron Queenan: "Re: How can I get the TreeNode from a System.Windows.Forms.Message message?"
- Previous message: Herfried K. Wagner [MVP]: "Re: Cycling between images increases memory usage"
- In reply to: Scytrax: "Re: Cycling between images increases memory usage"
- Next in thread: Herfried K. Wagner [MVP]: "Re: Cycling between images increases memory usage"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|