Basic PDS 7.00 "Program Memory Overflow" with Too Many CONST (61349)
This article was previously published under Q61349
SUMMARY
When used with the /V switch, the BC.EXE compiler that comes with
Microsoft Basic Professional Development System (PDS) version 7.00
produces a "Program memory overflow" error when compiling a program
that has approximately 680+ CONSTants. The compiler can still have up
to 13K "bytes free" of compiler workspace when reporting this error.
"Program memory overflow" also occurs when compiling the TEST1.BAS
program generated below using 756+ CONSTants with the BC /Fs (far
strings) option.
The CONST limits are improved in Basic PDS version 7.10, which can
handle significantly more CONSTants than Basic 7.00.
The error message "Program memory overflow" is misleading because
normally the compiler only gives that error when more than 64K of code
has been generated for the module being compiled. This error
represents a limitation of the compiler. This error is generated when
the number of CONSTants that can be included in a Basic module has
been exceeded.
MORE INFORMATION
The "Program memory overflow" error above is due to the amount of
internal overhead that the compiler sets aside to do its work with
CONSTants. The error message is not generated because of a lack of
compiler workspace. In this case, 13K "bytes free" is a valid number.
There is actually 13K of compiler workspace free. A different
limitation has been encountered -- the number of CONSTants BC.EXE can
handle.
The BC.EXE in QuickBasic version 4.50 and the BC.EXE compiler in Basic
versions 6.00b and 7.10 will successfully compile a program with over
1000 CONSTants.
Illustration
To demonstrate the limitation in 7.00, use the FIRST.BAS program below
to create the Basic program TEST1.BAS with "n" number of CONSTants.
For example, a TEST1.BAS program created with approximately 650
CONSTants will compile with no errors in Basic PDS 7.00. A program
with 680+ CONSTants compiled with BC /V gives "Program-memory
overflow" in Basic PDS 7.00.
As a comparison to versions earlier than 7.00, if you create a
TEST1.BAS program with 1000 CONSTants, it will compile correctly with
BC.EXE 4.50 and BC.EXE 6.00b (which have a greater capacity for
CONSTants than 7.00).
As a comparison to 7.10, in TEST1.BAS created below, 7.10 can handle
1100 CONSTants when compiled BC /V (but 1200 CONSTants gives "Program
memory overflow"). In TEST1.BAS created below, 7.10 can handle 2100
CONSTants when compiled BC /Fs (but 2200 CONSTants gives "Compiler out
of memory, 0 bytes free"). Basic 7.10 can thus handle many more
CONSTants than 7.00.
FIRST.BAS
FIRST.BAS prompts you for a number, and then creates another Basic
program, TEST1.BAS, with that many CONSTants. Compile the resulting
TEST1.BAS with BC /V or /Fs to test for compiler limitations.
DEFINT A-Z
CLS
INPUT "How many CONSTants to you want in the file: ", Num%
OPEN "test1.bas" FOR OUTPUT AS #1
beg$ = "CONST p"
equals$ = " ="
FOR i = 1 TO Num%
constant$ = beg$ + LTRIM$(RTRIM$(STR$(i))) + equals$ + STR$(i)
PRINT #1, constant$
NEXT
CLOSE
PRINT "File 'test.bas' successfully created"
END
Modification Type: |
Minor |
Last Reviewed: |
1/9/2003 |
Keywords: |
KB61349 |
|