Microsoft KB Archive/40154

= QB.EXE &quot;OUT OF MEMORY&quot; after SHELL to DOS PRINT, MODE, ASSIGN =

Article ID: 40154

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q40154



SUMMARY
The MS-DOS PRINT, MODE, and ASSIGN commands should not be run from the QuickBasic environment during a SHELL or from a SHELL statement in an executable program. The MS-DOS PRINT, MODE, and ASSIGN commands remain resident in memory after being invoked. Subsequent attempts to LOAD another QuickBasic program that is larger or adds more code to an existing program result in the error message &quot;OUT OF MEMORY.&quot; You must exit QuickBasic and reboot to eliminate this memory-fragmentation problem.



MORE INFORMATION
When the MS-DOS PRINT, MODE, and ASSIGN commands are invoked, they are loaded into memory above QuickBasic and the program loaded in the environment. This causes memory to become fragmented. Although there may be more memory above the resident commands, QuickBasic will not recognize this memory.

A QuickBasic program that SHELLs to an MS-DOS batch file containing the PRINT, MODE, or ASSIGN command usually executes correctly. However, if an attempt is made to unload the current program and load in a program that is larger than the first, the &quot;OUT OF MEMORY&quot; error message displays. If you exit QuickBasic and then bring QuickBasic up again, any attempt to load a program into the environment also generates the error message.

If any application invoked after this is larger than QuickBasic, the following error displays: &quot;PROGRAM TOO LARGE TO FIT IN MEMORY.&quot; The only way to alleviate this situation is to reboot the machine. Exiting QuickBasic and then running QB.EXE again does not eliminate the problem.

To work around this problem, invoke the MS-DOS PRINT, MODE, or ASSIGN command before running QB.EXE. You should never SHELL to any terminate-and-stay-resident (TSR) program (such as the MS-DOS PRINT, MODE, or ASSIGN command).

The following code example demonstrates the memory-fragmentation problem: cls print &quot;start&quot; shell &quot;test.bat&quot; print &quot;done&quot; end The following is the batch file TEST.BAT: mode com1:300,N,8,1,bin mode lpt1:=com1:

Additional query words: QuickBas BasicCom

Keywords: KB40154

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.