Machine Cramping Bitmaps 
Author Message
 Machine Cramping Bitmaps

Hi, no questions here, just a comment & warning for others to heed.

    I've been playing around with doing some programming with UserControls
that mimic another program that I've seen, but think could use a lot of
improvement.  They use a bitmap for one of their screens, so I figured I'd
just borrow the bitmap for my version and put it in a docked control.  The
bitmap was over 1200 KB, which is big, but for testing did not sound
daunting.

    When I compiled, my machine suddenly came to a crawl.  Checking the Task
Manager, I found that over 650 MB of memory was being allocated.  Now, I
have 512 MB of RAM, so thought I'd be ready for any simple project, but this
began eating up the hard disk space with the resultant swap time that
results.  I removed the .bmp file from my Control, but hitting the "build"
button didn't change the size of the resx file and it kept chomping up
memory.  Then I tried Rebuild All and got some errors, so, I removed the
.bmp file, and deleted the Debug and Obj folders before it would finally
correctly recompile the resource files.

    After a successful rebuild, my memory usage dropped back to around 185
MB.  Seeing this, I opened the .bmp file and changed it to a .gif file less
than 2% of the size of the original file.  I reintroduced this to the
UserControl and resulted in a successful running program that increased the
memory usage a mere 10 MB.

    So, while I did find a successful solution to my problem, I still wonder
what happens in memory that having a 1.2 MB .bmp as the BackgroundImage
results in about 450 MB of memory usage.  Any other bitmaps I borrow will be
turned to .gif files before I use them... but that 450 MB still bothers me.

Chris R



Fri, 21 May 2004 15:18:50 GMT  
 Machine Cramping Bitmaps
Chris,

    Your problem does sound odd to say the least.

    What I am curious about is how you displayed the bitmap in your control.
Did you use a picturebox or imagebox, or did you use some custom painting
routines?

    If you could post some code, that would help.

--
                              - Nicholas Paldino [.NET MVP]


Quote:
> Hi, no questions here, just a comment & warning for others to heed.

>     I've been playing around with doing some programming with UserControls
> that mimic another program that I've seen, but think could use a lot of
> improvement.  They use a bitmap for one of their screens, so I figured I'd
> just borrow the bitmap for my version and put it in a docked control.  The
> bitmap was over 1200 KB, which is big, but for testing did not sound
> daunting.

>     When I compiled, my machine suddenly came to a crawl.  Checking the
Task
> Manager, I found that over 650 MB of memory was being allocated.  Now, I
> have 512 MB of RAM, so thought I'd be ready for any simple project, but
this
> began eating up the hard disk space with the resultant swap time that
> results.  I removed the .bmp file from my Control, but hitting the "build"
> button didn't change the size of the resx file and it kept chomping up
> memory.  Then I tried Rebuild All and got some errors, so, I removed the
> .bmp file, and deleted the Debug and Obj folders before it would finally
> correctly recompile the resource files.

>     After a successful rebuild, my memory usage dropped back to around 185
> MB.  Seeing this, I opened the .bmp file and changed it to a .gif file
less
> than 2% of the size of the original file.  I reintroduced this to the
> UserControl and resulted in a successful running program that increased
the
> memory usage a mere 10 MB.

>     So, while I did find a successful solution to my problem, I still
wonder
> what happens in memory that having a 1.2 MB .bmp as the BackgroundImage
> results in about 450 MB of memory usage.  Any other bitmaps I borrow will
be
> turned to .gif files before I use them... but that 450 MB still bothers
me.

> Chris R



Fri, 21 May 2004 22:05:27 GMT  
 Machine Cramping Bitmaps
OK, now I can't repeat the problem.... however, I will give some information
in case anyone else has an idea of what mayb have happened.

This line is added when I click on the ... button under the UserControl
properties window, BackgroundImage.
I add a file called spacemap.bmp.
this.BackgroundImage =
((System.Drawing.Bitmap)(resources.GetObject("$this.BackgroundImage")));

Last night, when I had the trouble, I noticed that my Form1.resx file was
well over 1 MB in size... about 1.3+ if I recall... as I tried to recreate
the trouble this morning, I see the Form1.resx file, with the spacemap.bmp
as the BackgroundImage is only 76 KB in size.  Checking this file, I see
that
the XML code has
<data ...>
    <value>
        ...
information for my UserControl11.Background image.  This information is
greatly compress from the .bmp file, in base64 mimetype..
This leads me to wonder if, when I tried to add the bitmap file yesterday,
if the program misinterpretted the format and added in the bmp file rather
than encoding it.  Then it was trying to reinterpret the file as it read it
and thus was attempting to create a massive .bmp file from bad data.

Thus it would have put in the bmp dat and then tried to interpret it as if
it were base64 mimetype, resulting in a bmp so big that it could have held a
map of Seattle, WA in it. *tongue in cheek*

Oh yeah, it was a black and white image.  For colors, I'll use .jpeg rather
than .gif.  Wanted to point that out before someone else did.

Chris R



Quote:
> Chris,

>     Your problem does sound odd to say the least.

>     What I am curious about is how you displayed the bitmap in your
control.
> Did you use a picturebox or imagebox, or did you use some custom painting
> routines?

>     If you could post some code, that would help.

> --
>                               - Nicholas Paldino [.NET MVP]



> > Hi, no questions here, just a comment & warning for others to heed.

> >     I've been playing around with doing some programming with
UserControls
> > that mimic another program that I've seen, but think could use a lot of
> > improvement.  They use a bitmap for one of their screens, so I figured
I'd
> > just borrow the bitmap for my version and put it in a docked control.
The
> > bitmap was over 1200 KB, which is big, but for testing did not sound
> > daunting.

> >     When I compiled, my machine suddenly came to a crawl.  Checking the
> Task
> > Manager, I found that over 650 MB of memory was being allocated.  Now, I
> > have 512 MB of RAM, so thought I'd be ready for any simple project, but
> this
> > began eating up the hard disk space with the resultant swap time that
> > results.  I removed the .bmp file from my Control, but hitting the
"build"
> > button didn't change the size of the resx file and it kept chomping up
> > memory.  Then I tried Rebuild All and got some errors, so, I removed the
> > .bmp file, and deleted the Debug and Obj folders before it would finally
> > correctly recompile the resource files.

> >     After a successful rebuild, my memory usage dropped back to around
185
> > MB.  Seeing this, I opened the .bmp file and changed it to a .gif file
> less
> > than 2% of the size of the original file.  I reintroduced this to the
> > UserControl and resulted in a successful running program that increased
> the
> > memory usage a mere 10 MB.

> >     So, while I did find a successful solution to my problem, I still
> wonder
> > what happens in memory that having a 1.2 MB .bmp as the BackgroundImage
> > results in about 450 MB of memory usage.  Any other bitmaps I borrow
will
> be
> > turned to .gif files before I use them... but that 450 MB still bothers
> me.

> > Chris R



Fri, 21 May 2004 22:43:30 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Bitmaps don't load on some machines

2. Bitmaps don't load on some machines

3. assignment within conditional expression, cramps style

4. Display bitmaps in Print Preview and printing bitmaps.

5. printer font size changes from machine to machine

6. 8 bit (256 color) bitmaps vs 24 bit bitmaps

7. Font sizes change from machine to machine

8. How to get IP ADDRESS of a machine from machine name?

9. ATL COM dll won't instantiate from one version of IIS on one machine if compiled on different machine

10. Table locked by user <user> on machine <machine>

11. MFC App works fine on VC++4.2 machine, fails on new install machine.

12. This works with 256 color bitmaps; but 16bit color bitmaps

 

 
Powered by phpBB® Forum Software