MikeD
Fri Jan 07 18:07:36 CST 2005
"Hermione" <Hermione@discussions.microsoft.com> wrote in message
news:470C187A-F6A0-4B4B-BE12-1655F857F666@microsoft.com...
> Hi
>
> How can I minimize the Memory use by a process created with Vb6
There are LOTs of ways. However, your program is going to use whatever
memory it requires. It primarily comes down to optimizing your code and
your use of controls. Here are a few things to keep in mind:
1. Don't keep variables "alive" longer than necessary. This means using the
proper scope for your variables. If the data is only required for a single
procedure, then use a procedural-level variable.
2. Declare your variables for the proper data type. Don't use a Double (or
worse, a Variant) when a Long (or even Integer, although Longs are
marginally more efficient) is really all you need.
3. Use controls that require fewer resources and less memory. For example,
use Frames as containers instead of PictureBoxes and use Image controls
instead of PictureBoxes to display graphics. Of course, functionality comes
into play here. If the Frame or Image control doesn't provide the
functionality you need that the PictureBox does, then naturally you need to
use the PictureBox. Along with this, use Label controls for static data
(data the user doesn't need to edit) instead of TextBoxes.
4. Use arrays efficiently. By this, I mainly mean that you might dimension
an array much larger than is ultimately necessary for performance reasons
(to keep from having to rediminsion it over and over, which is
time-consuming), but after the array is filled, reduce its size accordingly.
5. Release objects once they are no longer needed. This kind of goes along
with #1.
These are all just general guidelines (and only a few of many at that). If
you want specific recommendations on what you could do, then you'd need to
provide specifics about your program, your code, what
objects/controls/libraries you're using, etc.
Lastly, you might want to take a look at the following:
How to Optimize Memory Management in VB 3.0 for Windows
http://support.microsoft.com/default.aspx?scid=kb;en-us;112860
Now while this article is targeted for VB3, many of its recommendations and
suggestions apply to all versions of VB (well, maybe not VB.NET). If you
haven't checked it already, MSDN Library (VB6's Help) has topics regarding
memory management and optimization as well. Here's the URL for it online
(or see the same topic in an installed copy of MSDN Library):
http://msdn.microsoft.com/library/en-us/vbcon98/html/vbcondesigningforperformancecompatibility.asp
Mike