Runtime error 7 (out of memory)
Hi, I wrote an application containing several progarms of
database maintenance and email sending in VB6. It works
well in my machine. But it found runtime error 7 (out of
memory) when I complied the programs in P-code mode
for distribution and reinstall it on a XP machine. Other
programs work okay except the program of sending email.
I tried to place some message boxes in the different areas
of the email program and found the runtime error upon
executing this program. I cannot locate where the problem
is. Any one can tell me what the problem is and how to help
me out.
Many thanks in advance!
:cry:
Re: Runtime error 7 (out of memory)
Compile to native code, don't use P-code unless you have to.
What dependencies does the app have?
Re: Runtime error 7 (out of memory)
I've had this problem in the past with string handling..the string gets too long and it goes out of scope resulting in the "out of memory" message - I'm pretty sure that "runtime error 7" message actually means that a particular item has overgrown it's allocated space. I suspect the entire email body is contained in a single string? If so, that's where I'd start....
Re: Runtime error 7 (out of memory)
Here is a quote from the MSDN documentation on this error:
Quote:
Originally Posted by MSDN
Out of memory (Error 7)
Specifics
More memory was required than is available, or a 64K segment boundary was encountered. This error has the following causes and solutions:
* You have too many applications, documents, or source files open.
Close any unnecessary applications, documents, or source files that are open.
* You have a module or procedure that's too large.
Break large modules or procedures into smaller ones. This doesn't save memory, but it can prevent hitting 64K segment boundaries.
* You are running Microsoft Windows in standard mode.
Restart Microsoft Windows in enhanced mode.
* You are running Microsoft Windows in enhanced mode, but have run out of virtual memory.
Increase virtual memory by freeing some disk space, or at least ensure that some space is available.
* You have terminate-and-stay-resident programs running.
Eliminate terminate-and-stay-resident programs.
* You have many device drivers loaded.
Eliminate unnecessary device drivers.
* You have run out of space for Public variables.
Reduce the number of Public variables.
For additional information, select the item in question and press F1.
Or, see here for all the information :)
Cheers,
RyanJ
Re: Runtime error 7 (out of memory)
Hi and thanks for information and suggestions.
My email message body is contained in one string. But no error is found when it runs on
my computer. Moreover, I found the runtime error occurred during the form load of the email program but no form screen was shown (hence no data is entered on the email message body string).
Regarding the memory, my program is very small and nos. of variables are also very limited. Hence, I think it is not the problem of insufficient memory.
For dependencies, I suspect if there are some dependencies' damage. After replacing
the dependencies upon re-installation, the runtime error still persists. I tried to install and run on another two clean XP computers (one is the same window version of the
previously-mentioned XP computer for test and encountering error) and found the problem is solved. Therefore, I think if there are some dependencies' damage which file(s) is/are not installed by my distribution program but orginally in the Windows XP.
But the problem is how I can locate which dependent file is damaged and hence fix
it !? Any suggestion?
(Compiling in P-Code mode is the consideration of program security and protection).
Re: Runtime error 7 (out of memory)
Use a Packaging /Installer program to create a setup package so you can safely deploy your program on to other systems.
Depending on which dependancies your app is using, an easy installer is the Package & Deployment Wizard that comes with Visual Studio.
Check out our Application Deployment forum's FAQ for links to some other packagers.
Re: Runtime error 7 (out of memory)
check out the upgrade level of XP on that machine and how much memory and free disk space it has compared to other machines where to program works.
pete
Re: Runtime error 7 (out of memory)
The problem I had with runtime error 7 didn't show itself on my pc either - I finally decided that was just one of those things that happens when VB is installed instead of just having the runtimes installed as the distributed to pc had. I dug through MSDN for days, asked everybody I could find to ask (and yea, you search this forum and you'll probably find where I was asking about it here) before I finally found somebody somewhere who said that runtime error 7 should, in most cases, actually report "out of scope"....
If you're sure it's not string related make sure you have Option Explicit invoked on all forms and in all modules so you'll know all of the variables are properly declared and not being dulpicated.
I'm still leaning toward it being a string problem tho...lol
Re: Runtime error 7 (out of memory)
Quote:
Originally Posted by Paulchow
(Compiling in P-Code mode is the consideration of program security and protection).
If you need security then I'd say native code is better. From my understanding, P-code is easily decompiled, whereas with native code the best you can do is recreate the forms and assembly listing. Could be wrong though.
Re: Runtime error 7 (out of memory)
Re: Runtime error 7 (out of memory)
Thanks for suggestions and useful information.
The tested computer's configuration is the same except the version of
Window OS (XP). I will check and re-test again. Thanks.
Re: Runtime error 7 (out of memory)
I recently encountered this error as well (on XP SP2) with an application that was set-up for XP visual styles, using "InitCommonControlsVB()". In other applications I didn't have to do this, but in this case I explicitly had to put a call to this procedure in my "Sub Main". Then the error disappeared as if it never occurred.
Re: Runtime error 7 (out of memory)
You should always call InitCommonControls/InitCommonControlsEx, unless your app already has a reference to the common controls. Otherwise as you say you can get errors when you start up.