Solved

Runtime error #7 - out of memory

Posted on 2001-06-06
14
2,007 Views
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.
0
Comment
Question by:krahd
  • 3
  • 3
  • 2
  • +5
14 Comments
 
LVL 8

Expert Comment

by:AJAY CHADHA
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 ... :-)
0
 
LVL 18

Expert Comment

by:deighton
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.
0
 
LVL 1

Expert Comment

by:morgan_peat
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.
0
 
LVL 6

Expert Comment

by:anthony_glenwright
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...
0
 

Author Comment

by:krahd
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.
krahd
0
 
LVL 6

Expert Comment

by:anthony_glenwright
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?
0
 

Author Comment

by:krahd
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.
Krahd.

P.S. Could it be a bug in ADO software?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 6

Expert Comment

by:anthony_glenwright
ID: 6166526
I'd be checking system resources, then.  Run sysinfo and have a look...
0
 
LVL 1

Expert Comment

by:morgan_peat
ID: 6166894
Theres a good knowledge base article about this: Q229756
(http://support.microsoft.com/support/kb/articles/Q229/7/56.ASP)

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.....
0
 

Accepted Solution

by:
bosley earned 300 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.

bosley

0
 

Author Comment

by:krahd
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,
   Krahd.



0
 

Expert Comment

by:bosley
ID: 6186045
krahd,

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()
   form2.show
end sub

You can also use "form2.show 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.

bosley
0
 
LVL 2

Expert Comment

by:JanusFury
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.
0
 
LVL 5

Expert Comment

by:Netminder
ID: 6909577
Force-accepted by
Netminder
CS Moderator
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now