SHELL Can Give "Out of Memory" Error or Fragment Memory (21902)



The information in this article applies to:

  • Microsoft QuickBASIC 2.0
  • Microsoft QuickBASIC 2.01
  • Microsoft QuickBASIC 3.0
  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System for MS-DOS 7.0

This article was previously published under Q21902

SUMMARY

Question:

Why do I get an "Out of Memory" error when I use the SHELL statement or the Shell command?

Response:

The SHELL statement does not clean up or compress memory. If not enough contiguous memory is available (for example, if many CHAIN statements have been executed, or several dynamic arrays were allocated then erased), a SHELL statement may fail with an "Out of memory" error. This includes both the Shell command from the File menu and also the SHELL statement in a running program.

Also, if you mistakenly install any TSR (terminate and stay resident) program during a SHELL command, you will fragment memory, which often results in an "Out of Memory" error. For example, if you run the QuickBasic environment, choose the Shell command from the File menu, install a TSR, EXIT the Shell, Exit the QuickBasic environment, and reinvoke the QuickBasic environment from DOS, then you get an "Out of Memory" error immediately before you can do anything in the environment. You must reboot to unfragment DOS memory.

This information applies to Microsoft QuickBasic Versions 2.00, 2.01, 3.00, 4.00, 4.00b, and 4.50, to Microsoft Basic Compiler Versions 6.00 and 6.00b for MS-DOS, and to Microsoft Basic PDS Version 7.00 for MS-DOS.

TSR programs should NEVER be installed during a SHELL statement or a Shell from the File menu. Examples of TSR programs are MSHERC.COM (from QuickBasic 4.50) and QBHERC.COM (from QuickBasic 4.00/4.00b and the Basic compiler 6.00/6.00b).

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB21902