Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Runtime error #7 - out of memory

Posted on 2001-06-06
Medium Priority
Last Modified: 2008-03-03
I've developed a Visual Basic 6.0 program that displays some data (gathered from a Access database throw ODBC). This program works fine in my computer, under Windows 2000 but in eveery other computer with Windows 9x shows a runtime error #7 "Out of memory".
Please help!!
thanks a lot

p.s. even in my own computer with windows 98 and the very same software installed gets the #7 error.
Question by:krahd
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +5

Expert Comment

ID: 6162654
Increase the virtual memnory size and make sure that you have installed the latest service pack i.e. SP5

Good Luck...
Ajay Chadha ... :-)
LVL 18

Expert Comment

ID: 6163008
Do you create any large arrays, strings or collections in your program?  

Use error handling code to check what it is doing when it runs out of memory.  

Don't hold huge amounts of data in memory.

Expert Comment

ID: 6163015
Are you getting back loads of data?
Your machine should basically have the same amount of memory as hard disk+RAM.
When running in Win2K, try using the performance monitor to make sure you haven't got a memory leak somewhere.
Check Process->Private Bytes->Your running app.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 6163936
Usually when I get this error, it's because of an infinite loop or infinite recursion problem.  Does it happen at design time as well?  If so, bung in a couple of break points or click ctrl-break and see what's happening...

Author Comment

ID: 6165179
Thank you all for your comments.
What I have is a form named fMainForm with a lot of controls in it.
I have 400+ textboxes and 200+comboboxes, divided in 11 "pages" using frames and a TabStrip (by toggling the visible propertie of the frames).
I have also, 6 forms that access some other data using dataGrids.
The program checks the database and fills the controls fMainForm up.
Then the user is allowed to make some changes, but when he tries to save them he gets the #7 error.
The amount if data involved is not really big, just what is needed to fill the controls up.
Every procedure I used is far smaller than 64kb, but the "text size" of fMainForm is 437 kb (300 just due controls declarations).
I do not have infinite loops, and the biggest collection I have has less than 60 objects.
Anyway, what I cannot explain is: why do I get the error udner windows 9x & ME but it does NOT appear under Windows 2000?

Thanks a lot again.

Expert Comment

ID: 6165885
You might be running out of system resources, with that many controls on a form.  I *think* in Win95 there's still a limit, it was just increased.

Are you using control arrays for the multiple text boxes and combo boxes?

Author Comment

ID: 6166516
Hi again.
I'm using control arrays for both text and combo boxes.
I use one array for each type of control for each page. Id est I have 22 arrays (11 per type).

I forgot to mention that there are a lot of labels too, one per control (describing the info contained) Arranged in one array per page, too.

Thanks again.

P.S. Could it be a bug in ADO software?

Expert Comment

ID: 6166526
I'd be checking system resources, then.  Run sysinfo and have a look...

Expert Comment

ID: 6166894
Theres a good knowledge base article about this: Q229756

I quote:
"Although you can have up to 254 control names in a form ... In some cases, you will experience out-of-memory error. ".

It also explains a few ways to get around it (i.e. UserControls, control arrays).
Best way is to try and cut down the size of your forms though.....

Accepted Solution

bosley earned 1200 total points
ID: 6181748
Hi krahd, we have just gone through the exact same problem on our project.  I had a form with a grid and 2 tab controls.  The main tab control had 8 tabs and about 50-60 controls on it.  We found we had to break this form up. When this form was loaded our Win 95 systems took over a 25% resource hit (looking at the resource monitor).  what we did was to break up each of the tabs to a sub-form that is loaded on the click of a button from the main form (fMainForm).  So instead of 8 tabs we have 8 buttons. From the user's point of view they either have to click on the tab they want (old version) or a button (new version).  This reduced the resource hit from 25% to about 5%.  Your case may be a lot more of a savings because you have more controls than we did.

Just a suggestion.



Author Comment

ID: 6185125
Hi again.
First af all I would like to give thanks to all who took the time to answer. Thans :)

Bosley: As far as I remember the subform (a la Access) feature isn't present in Visual Basic...
but if it is, could you please tell me how to do it? :)

(I've made a prototype where another form was loaded by frmMain (but not a subform) but it was rejected...)

Thanks again,


Expert Comment

ID: 6186045

You create a forms (nothing special about the forms I just call them "sub forms") that contains the controls from your tabs. Next, you replace your tab control with, for example, buttons.  Each button corresponding to one tab on the tab control you removed. In the click event of the buttons on the main form you will open the corresponding form containing the controls previously on your tab:

private sub button1_click()
end sub

You can also use " vbModal" if you want the user to complete that form and close it (I assume this would trigger a save) before continuing with other processing on your main form.

I would suggest that each "sub form" corresponds to one table of data to make the inserts and updates, etc a lot more straight forward.

Hope this helps.


Expert Comment

ID: 6697706
Using that many controls is sure to cause your problem. I suggest using a static number of text boxes, and having them visible no matter what tab is chosen... then change the appearance of them to reflect the chosen tab.

Expert Comment

ID: 6909577
Force-accepted by
CS Moderator

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question