Out of String Space

 BBS: Inland Empire Archive
Date: 04-14-92 (08:39)             Number: 96
From: MATT HART                    Refer#: NONE
  To: JASON GORMLEY                 Recvd: NO  
Subj: Out of String Space            Conf: (2) Quik_Bas
 JG> OUT OF STRING SPACE. My question is this... Has anyone else had a
 JG> problem with this, and what are my options in getting rid of this
 JG> troblesome error??

Here's a canned message for explaining QB memory usage.
It'll help with understanding assembly linkage, string
space problems and solutions, and other advanced stuff.
Unless otherwise noted, all references will be to QB 4.5.

QB uses memory in several distinct ways.  They are:
    Code Segments
    DGroup (Data Group)
    Far Heap

First, Code Segments:
    This is the actual EXE file space taken by your program's
    instructions.  It can be reduced by compiling with /O
    (stand alone).  The actual EXE file will be larger, but it
    will probably have less than the BRUN45.EXE (also in the
    code segment memory) and your EXE file put together.  Also,
    don't compile a final product with /D (debug).  This bloats
    your EXE file size by 5-10K and makes it slower.  Use it
    during programming only.  Use /X (extended error trapping)
    only when absolutely neccessary.  When possible, move the
    portion of code requiring /X to a SUB module, as it also
    adds 5-10K of code.  Any one .BAS source code file MUST
    compile to less than 64K of code.  More than one 64K file
    can be linked together to create large EXE files, but this
    stricture is required so that GOTO's and GOSUB's work
    properly - they are near jumps within a segment of memory.
    If a program makes lots of CALL's to the same routine, put
    that CALL into a GOSUB.  GOSUB's take only a few bytes, but
    CALL's take 80 bytes plus a couple for every parameter.

Second, DGroup:
    This is the most widely used and abused portion of QB.  Out
    of String Space, Out of Stack Space, String Space Corrupt, and
    most "masked" error messages are a result of problems in dgroup
    (a masked error is a recieved message (like String Space Corrupt)
    that is not the ACTUAL error (which might have been a "Subscript
    Out Of Range")).  Dgroup is a fixed 64K segment of memory that
    holds the following:

        The Stack : Default size is 3K.  This holds parameters used
        in CALL's, return address' for CALL and GOSUB.  Improperly
        nested menus and GOSUB's without RETURN's will eventually
        result in an Out Of Stack Space.  Proper usage should allow
        the 3K default to be plenty.

        COMMON Data Area : Area used to track the address' of
        variable in COMMON between CHAINed EXE programs and
        between SUB/FUNCTION procedures and the main module.


 * Origin: Midnight Micro!  V.32/REL  (918)451-3306 (1:170/600)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET