Microsoft KB Archive/65034

= QBX.EXE &quot;Out of Data Space&quot; for Variable-Length String Array =

Article ID: 65034

Article Last Modified on 10/20/2003

-

APPLIES TO


 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q65034



SUMMARY
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 &quot;Out of Data Space&quot; and &quot;Out of Memory&quot; 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 &quot;Out of String Space&quot; message at run time when allocating dynamic variable-length string arrays and how you can get a &quot;LINK : Fatal error L2041: Stack plus data exceed 64K&quot; 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 &quot;Out of Data Space&quot; followed by &quot;Out of Memory&quot; 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 &quot;This never prints in QBX.EXE&quot; 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 &quot;LINK : Fatal error L2041: Stack plus data exceed 64K&quot; 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 &quot;Out of Data Space&quot; followed by &quot;Out of Memory&quot; at run time in QBX.EXE when the program reaches REDIM A$(12000). From a compiled .EXE program, an &quot;Out of String Space&quot; 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 &quot;DIM a$(&quot;; j * 1000; &quot;)&quot;; &quot; Far string segment usage=&quot;; FRE(a$) ' STACK returns the space available in DGROUP: PRINT &quot;DGROUP available=&quot;; STACK NEXT

