Re: Resource Management -- Preventing Crashes

Tech-Archive recommends: Speed Up your PC by fixing your registry



As a followup, I did some further investigating as this simply wasn't making
any sense. I got ahold of the raw code for a user control that I had
downloaded to replace the Windows sliderbar control, as I needed some
additional functionality.

It turns out that some bonehead developed this user control using 12 picture
boxes, each containing small bitmaps that were then bitblt'd and
stretchblt'd to give the appearance of a single image. Needless to say, just
1 of these user controls used an insane amount of GDI and USER objects.

I recoded the entire user control with 12 image controls and a single
picture object, reducing the overhead by well over 90%. With just swapping
out these controls, my project reduced it's overhead by nearly 75% and runs
just fine when multiple window instances are open.

I just wish folks would write ActiveX controls with some common sense in
mind. If stuff was developed on PCs with crummy CPUs and 16MB video cards,
these problems would show up much more quickly. So I digress. I plan to
upload my version of the user control to PlanetSource shortly.

Evan


"Thorsten Albers" <albersRE@xxxxxxxxxxxxxxxxxxx> wrote in message
news:01c73513$1ee93840$9d4bf8d9@xxxxxxxxxxx
wxforecaster <wxforecaster@xxxxxxxxx> schrieb im Beitrag
<#3ixsBHNHHA.4244@xxxxxxxxxxxxxxxxxxxx>...
Bottom line...I have an application with a form that I honestly didn't
think
had that much *stuff* on it (a couple picture boxes, a toolbar, some
buttons, background DCs to increase paint time). When I load 1 or 2
forms,
no problem. When I spawn 3-4 of these forms, the computer begins to go
downhill with failures mentioned above. In otherwords, what factor(s)
prevent me from loading 5 forms or 50 forms and how can that be measured
so
corrective action can be taken.

With 1GB of RAM and 128MB of video RAM, I'm concerned that I've done
something terribly wrong. The code has been thoroughly checked and
tested
with a GDI resource tracker and it is 100% leak free. I used the
GuiResTracer which shows GDI and USER objects to test for leaks, but that

doesn't help me understand what 1 unit of these objects is equal to, or
what
the upper limit is, etc...

There are some simple rules:
- Try to avoid the VB AutoRedraw property where possible - and since
everything can be done in the paint event it is always possible
- Try to use the VB ImageBox control instead of the PictureBox control
- Create a GDI object only and immediately before it is needed, and
destroy/delete it as soon as possible
- If your application has performance problems try to avoid controls, draw
that what has to be drawn (and only that!) in the paint event, clip
drawing
to the visible part of the drawing surface, and draw only that what really
needs to be redrawn (GetUpdateRectangle()).

--
----------------------------------------------------------------------
THORSTEN ALBERS Universität Freiburg
albers@
uni-freiburg.de
----------------------------------------------------------------------



.


Quantcast