Results 1 to 13 of 13

Thread: Runtime error 7 (out of memory)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Location
    Hong Kong
    Posts
    19

    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!


  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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?

  3. #3
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

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

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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
    My Blog.

    Ryan Jones.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Location
    Hong Kong
    Posts
    19

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

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    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.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  8. #8
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    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

  9. #9
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

  10. #10
    Banned randem's Avatar
    Join Date
    Oct 2002
    Location
    Maui, Hawaii
    Posts
    11,385

    Re: Runtime error 7 (out of memory)


  11. #11

    Thread Starter
    Junior Member
    Join Date
    Apr 2004
    Location
    Hong Kong
    Posts
    19

    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.

  12. #12

    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.

  13. #13
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width