Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory usage

Status
Not open for further replies.

tlhawkins

Programmer
Dec 28, 2000
797
US
Hello all,

I recently found that a program I wrote runs out of memory on win98. The changes that I have made recently that may have affected this change are very small. I have only one form that has more then 10 controls on it.

I have a form with 17 checkboxes ( I added one recently ). 7 text inputs, 6 drop lists, a tree view, a couple of image boxes, and a Tab control. That to me doesn't seem like a huge form.

But the only thing I can think that I added was one checkbox to that form.

After that I went over my code with a fine tooth comb and found several large arrays (10-15k) that I had been keeping that were not necessary. I removed those and still it runs out of memory.

What I would like to know from everyone is any tips for lowering memory usage.

For instance I use 3 modules with many public functions and subs would it be better to move these into a form and make them private. or no...

should I move more functions in to modules?

Any tips would be apprecaited.
Thanks
 
Before I did anything more to my program, I would carefully rule out anything else. First, have you tried this on more than one Win98 system, and are you getting the same error? If not, you could have some trouble with your hardware.

The size of your app doesn't suggest a memory problem to me either.

Good luck,

Bob
 
Good ideas,

I did try it on a couple of 98 systems , one was a fresh install. Both did the same thing. Also it seems like the Out of Memory (Error 7) happens very early on in the loading. It must be something obvious if I just knew what to look for.

 
also if you still have the old exe try it out if you can. Depending on when you get the error is could be caused by a recursive call, direct or indirect. This includes events triggering recursion.
 
I think imageBox could took lots of memory.
(if you load big picture or just set huge control size).

Does this "out of memory" thing happens in IDE? If it does, that line it stops?
(that is what part of code causes problem)?

Is it in form.load? Do you doing anything there?

 
A good debugging technique for a hidden problem like this is to put msgbox functions in your code and to compile it.
For instance, your saying that your error is occuring during loading. In your form load, first line, put MsgBox "Starting form load", vbOKOnly, "Debugging", and so on throughout your code. This might help you determine the exact location of where your error is being raised.

Hope this helps?
 
Also, you might want to eliminate any variant data types you might have, or convert any large arrays full of static(unchangeing) data to sequential files.
 

And I will suggest form size and screen resolution on design versus target machines.

Symptoms:

Start EXE and before form shows a message box pops up with the out of memory error #7.

Solutions:

See above and possibly the following example...

Design environment with a screen resolution of 800x600.
Forms WindowState = vbNormal
Forms Width = 12000
Forms Height = 8000

Program works fine on design computer and fills screen as it should.

On target machine resolution is set to 640x480 making maximum form size width = 9600 and the forms height = 7200, which makes the designed form too large to display and you run out of memory.

This has happened to me on older systems or less expensive video cards.

It is just one possibility.

Good Luck


 
Using Msgboxes isn't that great of an idea to track down bugs. Msgboxes change the event sequences and speed of your application thus you may not find the error you are looking for because the event that was causing may not occur or may occur in a diffent order which appears to take away the bug. Use of something like a debug component which lets you pump info to another app doesn't usually effect speed that much and shouldn't effect the event sequence.
 
Any chance of an uncontrolled recursive function/event call? You'll get a out of memory error for that pretty quick.

Chip H.
 
maybe,

would that happen if a timer was set with too short of an interval and called itself before it could return?

I can't think of any other that might.

Thanks everyone for all your help. I've been trying many of your suggestions, they are all improving my code a lot.

I would love to hear more.
 
Are you using Redim on any arrays? You may have lost control of the size of one of your arrays. Watch out for error or event logging to arrays. Dimension them with Integers instead of Longs and you will find out soon enough.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top