KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q65034: QBX.EXE "Out of Data Space" for Variable-Length String Array

Article: Q65034
Product(s): See article
Version(s): 7.00 7.10 | 7.00 7.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | | mspl13_basic
Last Modified: 4-SEP-1990

The 4-byte string descriptor for each variable-length string resides
in DGROUP (the 64K near heap) regardless of the compiler string option
(near or far).

When using the far strings option (BC /Fs option, or running within
QBX.EXE), only the contents (not the 4-byte descriptors) of the
variable-length string are stored in the far segments. Large string
arrays (near or far) can quickly fill up DGROUP with string
descriptors, as shown in the examples below.

This article illustrates how you can get both "Out of Data Space" and
"Out of Memory" messages in QBX.EXE using an empty variable-length
string array (dynamic or static) that fills up DGROUP with 4-byte
string descriptors.

This article also illustrates how, from a compiled .EXE program, you
can get an "Out of String Space" message at run time when allocating
dynamic variable-length string arrays and how you can get a "LINK :
Fatal error L2041: Stack plus data exceed 64K" message at LINK time
when allocating static variable-length string arrays, due to filling
up DGROUP with 4-byte string descriptors.

This information applies to Microsoft BASIC Professional Development
System (PDS) versions 7.00 and 7.10 for MS-DOS and MS OS/2.

Code Example 1 (Static Array)
-----------------------------

This example shows size limits using a static array of variable-length
strings.

This DIM gives "Out of Data Space" followed by "Out of Memory" in
QBX.EXE before the PRINT can be executed. The string descriptors (4
bytes per string-array element) are using up all the memory in DGROUP.

   PRINT "This never prints in QBX.EXE"
   DIM b$(12000)    ' Note:  DIM b$(11000) works without error.

If you compile this program with BC /Fs to a .EXE program, you can
specify up to about DIM b$(14000) without error. DIM b$(15000) gives
the LINK.EXE error "LINK : Fatal error L2041: Stack plus data exceed
64K" because DGROUP is filled up with string descriptors.

Code Example 2 (dynamic array)
------------------------------

This example shows size limits using a dynamic array of
variable-length strings.

The following program gives "Out of Data Space" followed by "Out of
Memory" at run time in QBX.EXE when the program reaches REDIM
A$(12000). From a compiled .EXE program, an "Out of String Space"
message occurs at REDIM A$(16000) or larger, again because DGROUP is
filled up with string descriptors.

Note that each string element has 2 additional bytes of overhead per
element in the far heap segment (even for this array that is empty of
any string contents).

CLS
FOR j = 5 TO 16
REDIM a$(j * 1000)
PRINT "DIM a$("; j * 1000; ")"; " Far string segment usage="; FRE(a$)
' STACK returns the space available in DGROUP:
PRINT "DGROUP available="; STACK
NEXT

References:

See Pages 719-720, "Variable Storage and Memory Use," and also Chapter
11, "Advanced String Storage," in the "Microsoft BASIC 7.0:
Programmer's Guide" for BASIC PDS versions 7.00 and 7.10.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.