Home All Groups Group Topic Archive Search About

ImageList - Memory-Issue in vs2005

Author
27 Apr 2006 3:20 PM
Michael Maes
Hi,

We have been using ImageLists in our Projects extensively.
Many forms have two ILs with nearly 900 bmp's each.
They are configured: 32Bit, Fuchsia, 16x16 (and one 24x24).

In VS2003 there was no issue with this.
Upgrading to VS2005 however makes it impossible to open those forms in
Design-View.
We have tested it with a blank project, and yes, even then it does not work.

-Take a clean project
-Add a form
-Add 2 ImageLists
-Set to 32bit, 16x16 & 24x24, Fuchsia
-Add about 900 bitmaps to each list
-Save
-Close form
-Close VS
-Open VS & SLN
-Open Form in Designmode

Watch the PageFile go up and up up and up up and up.... finally down and
down down and down down and down....

But no form is drawn.

I have tested it on machines with 3Ghz, 2,16GHz (Centrino Duo), Xeon Dual
Proc, all ranging from 1 to 2 GHz Memory. Just to say they are "quite
performant".

Is this a (known) bug or a ImageList limitation?

TIA,


Michael

Author
27 Apr 2006 7:43 PM
AMDRIT
I am not noticing a real issue on my machine.  Other than the resource files
are huge and there is a load time (~30 secs) while loading the imagelist's
stream.  It seems to be just as fast to populate the images collection from
bitmaps on the harddrive.  Perhaps you can alter your solution so that you
are not embedding the graphics in the exe.

Here is my test,  given a form, place a checkbox, a numeric updown box, a
picturebox, and three imagelists on the form.  To generate the 900 images,
uncomment the code in Form1_Load (Make sure you comment after the first run
so that #1 load times are not affected, #2 the application doesn't crash
trying to save the bitmap to disk.)

Once you have the images, add the 900 images to imagelist1 and imagelist2.
imagelist3 will load them from bmps on the drive.

System Spec's Dell 2.8GHz, 1GB RAM.  I should note that I have several
office docs open, three VS IDE's open, virus scan, media player, outlook,
outlook express, and two windows explorer windows.

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

    For i As Integer = 1 To 900
      '  Dim bmp As Bitmap

      '  bmp = New Bitmap(16, 16,
System.Drawing.Imaging.PixelFormat.Format32bppRgb)

      '  For x As Integer = 0 To 15
      '    For y As Integer = 0 To 15
      '      bmp.SetPixel(x, y,
System.Drawing.Color.FromArgb(CInt(Int((Integer.MaxValue - 1 + 1) * Rnd() +
1))))
      '    Next
      '  Next

      '  Me.ImageList2.Images.Add(i.ToString, bmp)
      '  bmp.Save(String.Format("C:\Pictures\temp\{0}.bmp", i))
      '  'bmp.Dispose()

      Dim sFile As String
      sFile = String.Format("C:\Pictures\temp\{0}.bmp", i)
      Me.ImageList3.Images.Add(i, New Bitmap(sFile))
    Next

    Me.NumericUpDown1.Minimum = 0
    Me.NumericUpDown1.Maximum = Me.ImageList3.Images.Count - 1
    Me.NumericUpDown1.DecimalPlaces = 0

  End Sub

  Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged

    Dim g As System.Drawing.Graphics

    g = Me.PictureBox1.CreateGraphics
    g.Clear(Color.Black)

    If CheckBox1.Checked Then
      Try
        g.DrawImage( _
              Me.ImageList3.Images(CType(Me.NumericUpDown1.Value, Integer)),
0, 0)
      Catch ex As Exception
        '
      End Try
    Else
      Try
        g.DrawImage( _
              Me.ImageList2.Images(CType(Me.NumericUpDown1.Value, Integer)),
0, 0)
      Catch ex As Exception
        '
      End Try
    End If

  End Sub


Show quoteHide quote
"Michael Maes" <michael.maes@community.nospam> wrote in message
news:C0B5551A-B8EE-4B25-B620-93B82DFDB9BF@microsoft.com...
> Hi,
>
> We have been using ImageLists in our Projects extensively.
> Many forms have two ILs with nearly 900 bmp's each.
> They are configured: 32Bit, Fuchsia, 16x16 (and one 24x24).
>
> In VS2003 there was no issue with this.
> Upgrading to VS2005 however makes it impossible to open those forms in
> Design-View.
> We have tested it with a blank project, and yes, even then it does not
> work.
>
> -Take a clean project
> -Add a form
> -Add 2 ImageLists
> -Set to 32bit, 16x16 & 24x24, Fuchsia
> -Add about 900 bitmaps to each list
> -Save
> -Close form
> -Close VS
> -Open VS & SLN
> -Open Form in Designmode
>
> Watch the PageFile go up and up up and up up and up.... finally down and
> down down and down down and down....
>
> But no form is drawn.
>
> I have tested it on machines with 3Ghz, 2,16GHz (Centrino Duo), Xeon Dual
> Proc, all ranging from 1 to 2 GHz Memory. Just to say they are "quite
> performant".
>
> Is this a (known) bug or a ImageList limitation?
>
> TIA,
>
>
> Michael
>
Author
27 Apr 2006 7:57 PM
AMDRIT
You are correct about the closing of the project and re-opening though.  My
IDE, crashed when I reopened the file, and that was after 10 min with very
little available resources.  Wow.  I would recommend a seperate resource
file or reading the bmp's directly from disk.


Show quoteHide quote
"AMDRIT" <amd***@hotmail.com> wrote in message
news:%23XSEOLjaGHA.4788@TK2MSFTNGP02.phx.gbl...
>I am not noticing a real issue on my machine.  Other than the resource
>files are huge and there is a load time (~30 secs) while loading the
>imagelist's stream.  It seems to be just as fast to populate the images
>collection from bitmaps on the harddrive.  Perhaps you can alter your
>solution so that you are not embedding the graphics in the exe.
>
> Here is my test,  given a form, place a checkbox, a numeric updown box, a
> picturebox, and three imagelists on the form.  To generate the 900 images,
> uncomment the code in Form1_Load (Make sure you comment after the first
> run so that #1 load times are not affected, #2 the application doesn't
> crash trying to save the bitmap to disk.)
>
> Once you have the images, add the 900 images to imagelist1 and imagelist2.
> imagelist3 will load them from bmps on the drive.
>
> System Spec's Dell 2.8GHz, 1GB RAM.  I should note that I have several
> office docs open, three VS IDE's open, virus scan, media player, outlook,
> outlook express, and two windows explorer windows.
>
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
>    For i As Integer = 1 To 900
>      '  Dim bmp As Bitmap
>
>      '  bmp = New Bitmap(16, 16,
> System.Drawing.Imaging.PixelFormat.Format32bppRgb)
>
>      '  For x As Integer = 0 To 15
>      '    For y As Integer = 0 To 15
>      '      bmp.SetPixel(x, y,
> System.Drawing.Color.FromArgb(CInt(Int((Integer.MaxValue - 1 + 1) * Rnd()
> + 1))))
>      '    Next
>      '  Next
>
>      '  Me.ImageList2.Images.Add(i.ToString, bmp)
>      '  bmp.Save(String.Format("C:\Pictures\temp\{0}.bmp", i))
>      '  'bmp.Dispose()
>
>      Dim sFile As String
>      sFile = String.Format("C:\Pictures\temp\{0}.bmp", i)
>      Me.ImageList3.Images.Add(i, New Bitmap(sFile))
>    Next
>
>    Me.NumericUpDown1.Minimum = 0
>    Me.NumericUpDown1.Maximum = Me.ImageList3.Images.Count - 1
>    Me.NumericUpDown1.DecimalPlaces = 0
>
>  End Sub
>
>  Private Sub NumericUpDown1_ValueChanged(ByVal sender As System.Object,
> ByVal e As System.EventArgs) Handles NumericUpDown1.ValueChanged
>
>    Dim g As System.Drawing.Graphics
>
>    g = Me.PictureBox1.CreateGraphics
>    g.Clear(Color.Black)
>
>    If CheckBox1.Checked Then
>      Try
>        g.DrawImage( _
>              Me.ImageList3.Images(CType(Me.NumericUpDown1.Value,
> Integer)), 0, 0)
>      Catch ex As Exception
>        '
>      End Try
>    Else
>      Try
>        g.DrawImage( _
>              Me.ImageList2.Images(CType(Me.NumericUpDown1.Value,
> Integer)), 0, 0)
>      Catch ex As Exception
>        '
>      End Try
>    End If
>
>  End Sub
>
>
> "Michael Maes" <michael.maes@community.nospam> wrote in message
> news:C0B5551A-B8EE-4B25-B620-93B82DFDB9BF@microsoft.com...
>> Hi,
>>
>> We have been using ImageLists in our Projects extensively.
>> Many forms have two ILs with nearly 900 bmp's each.
>> They are configured: 32Bit, Fuchsia, 16x16 (and one 24x24).
>>
>> In VS2003 there was no issue with this.
>> Upgrading to VS2005 however makes it impossible to open those forms in
>> Design-View.
>> We have tested it with a blank project, and yes, even then it does not
>> work.
>>
>> -Take a clean project
>> -Add a form
>> -Add 2 ImageLists
>> -Set to 32bit, 16x16 & 24x24, Fuchsia
>> -Add about 900 bitmaps to each list
>> -Save
>> -Close form
>> -Close VS
>> -Open VS & SLN
>> -Open Form in Designmode
>>
>> Watch the PageFile go up and up up and up up and up.... finally down and
>> down down and down down and down....
>>
>> But no form is drawn.
>>
>> I have tested it on machines with 3Ghz, 2,16GHz (Centrino Duo), Xeon Dual
>> Proc, all ranging from 1 to 2 GHz Memory. Just to say they are "quite
>> performant".
>>
>> Is this a (known) bug or a ImageList limitation?
>>
>> TIA,
>>
>>
>> Michael
>>
>
>