EDN Admin
Well-known member
I have a two Windows Form Program that is a picture database and slide show. The
slide show continuously updates the displayed picturebox without incrementing the
memory used with each new switch of picture. However, I have a second form that
has 50 pictureboxes that are meant to display thumbnails of pictures to be added to the database. As each picturebox of size(57,40) is added the memory used by the IDE rises to a little over 1GB on my 32bit XP system, from about 660MB, after
all pictures are displayed.
Once all the pictures are displayed as thumbnails, a mouse click on any of the 50 pictureboxes on the panel containing all thumbnails updates a single large picturebox on the form itself to display the picture in a single picture box with a size(1024,768).
When any thumbnail is clicked, the single large Picture box displays its associated picture from a file, but at the same time, system memory increments about 40KB per click event. Eventually, at around 2.3GB of system memory used, the program crashes with
an Out of Memory error.
How can I get the program to recover the memory used by the same picturebox when
it is updated with just another picture?
Partial Code below:
Each Thumbnail has a click event
<span style="font-family:"Courier New" <span> Private Sub PB49_Click(sender As System.Object, e As System.EventArgs) Handles PB49.Click PB49 is a PictureBox Thumbnail
<span style="font-family:"Courier New" <span> If PB(49) = 1 Then PB(49) = 0 Else PB(49) = 1
<span style="font-family:"Courier New" PB(50) is an Integer Array flagging Pictures to add
<span style="font-family:"Courier New" If PB(49) = 1 Then
<span style="font-family:"Courier New" <span> CheckBox49.Checked = True Tiny Checkbox on thumbnail
<span style="font-family:"Courier New" <span> F$ = ListAddFiles.Items(48)ListFileBox of FileNames
<span style="font-family:"Courier New" <span> PBx1.Image = Image.FromFile(F$)Gets filename and path
<span style="font-family:"Courier New" <span> PBx1.Visible = True Large PictureBox (1024,768)shows Pic F$
<span style="font-family:"Courier New" <span> Else
<span style="font-family:"Courier New" <span> CheckBox49.Checked = False
<span style="font-family:"Courier New" <span> PBx1.Image = Nothing<br/>
<span style="font-family:"Courier New" PBx1.Visible = False
<span style="font-family:"Courier New" <span> End If
<span style="font-family:"Courier New" <span><br/>
<span style="font-family:"Courier New" End Sub
<span style="font-family:"Courier New" I am using Visual Studio Ultimate SP1 updated<br/>
<br/>
View the full article
slide show continuously updates the displayed picturebox without incrementing the
memory used with each new switch of picture. However, I have a second form that
has 50 pictureboxes that are meant to display thumbnails of pictures to be added to the database. As each picturebox of size(57,40) is added the memory used by the IDE rises to a little over 1GB on my 32bit XP system, from about 660MB, after
all pictures are displayed.
Once all the pictures are displayed as thumbnails, a mouse click on any of the 50 pictureboxes on the panel containing all thumbnails updates a single large picturebox on the form itself to display the picture in a single picture box with a size(1024,768).
When any thumbnail is clicked, the single large Picture box displays its associated picture from a file, but at the same time, system memory increments about 40KB per click event. Eventually, at around 2.3GB of system memory used, the program crashes with
an Out of Memory error.
How can I get the program to recover the memory used by the same picturebox when
it is updated with just another picture?
Partial Code below:
Each Thumbnail has a click event
<span style="font-family:"Courier New" <span> Private Sub PB49_Click(sender As System.Object, e As System.EventArgs) Handles PB49.Click PB49 is a PictureBox Thumbnail
<span style="font-family:"Courier New" <span> If PB(49) = 1 Then PB(49) = 0 Else PB(49) = 1
<span style="font-family:"Courier New" PB(50) is an Integer Array flagging Pictures to add
<span style="font-family:"Courier New" If PB(49) = 1 Then
<span style="font-family:"Courier New" <span> CheckBox49.Checked = True Tiny Checkbox on thumbnail
<span style="font-family:"Courier New" <span> F$ = ListAddFiles.Items(48)ListFileBox of FileNames
<span style="font-family:"Courier New" <span> PBx1.Image = Image.FromFile(F$)Gets filename and path
<span style="font-family:"Courier New" <span> PBx1.Visible = True Large PictureBox (1024,768)shows Pic F$
<span style="font-family:"Courier New" <span> Else
<span style="font-family:"Courier New" <span> CheckBox49.Checked = False
<span style="font-family:"Courier New" <span> PBx1.Image = Nothing<br/>
<span style="font-family:"Courier New" PBx1.Visible = False
<span style="font-family:"Courier New" <span> End If
<span style="font-family:"Courier New" <span><br/>
<span style="font-family:"Courier New" End Sub
<span style="font-family:"Courier New" I am using Visual Studio Ultimate SP1 updated<br/>
<br/>
View the full article