Announcement

Collapse
No announcement yet.

Memory Limits

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Memory Limits

    I am curently maintaining and upgrading some legacy code. The
    recent changes I made push the exe to very near the memory
    limit. So close that some of the features now cause an error
    7. Any hints on how to reduce the size of the exe so I can
    add new stuff. Also does any one know if comments are
    comipiled or ignored?

    Thanks
    Brian

    ------------------

  • #2
    Brian,
    Comments are ignored, not compiled.
    You can help reduce EXE size by using some of the following. Of course, you can't turn off the features if you need them!
    Try them (and the other options outlined in the helpfile) to see if they help.

    Paul.
    Code:
    $CPU 80386                ' run on 80386+ cpu's
    $OPTIMIZE SIZE            ' make as small as possible
    $DEBUG PBDEBUG OFF        ' don't include pbdebug support in our executable
    
    $LIB COM        OFF       ' turn off PowerBASIC's communications library.
    $LIB CGA        OFF       ' turn off PowerBASIC's CGA graphics library.
    $LIB EGA        OFF       ' turn off PowerBASIC's EGA graphics library.
    $LIB VGA        OFF       ' turn off PowerBASIC's VGA graphics library.
    $LIB LPT        OFF       ' turn off PowerBASIC's printer support library.
    $LIB IPRINT     OFF       ' turn off PowerBASIC's interpreted print library.
    $LIB FULLFLOAT  OFF       ' turn off PowerBASIC's floating point support.
    
    $ERROR BOUNDS   OFF       ' turn off bounds checking
    $ERROR NUMERIC  OFF       ' turn off numeric checking
    $ERROR OVERFLOW OFF       ' turn off overflow checking
    $ERROR STACK    OFF       ' turn off stack checking
    
    $FLOAT NPX                ' use floating point hardware only, not emulation        
    
    $COM    16                ' set communications buffer size to something small
    $STRING 32                ' set largest string size at 32k
    $STACK  2048              ' use a 2k stack or smaller
    $SOUND  1                 ' smallest music buffer possible
    
    
    $OPTION CNTLBREAK OFF     ' don't allow Ctrl-Break to exit program
    $OPTION GOSUB OFF         ' don't preserve GOSUB stack on error


    ------------------

    Comment


    • #3
      You could also consider breaking the program up into several
      smaller programs, & then relying on SHELL, CHAIN or RUN to hop
      between them.

      Also, if by chance you have not already checked out how to get
      the max possible memory via settings on your CONFIG.SYS file,
      you should of course do that.

      ------------------

      Comment


      • #4
        Use $DYNAMIC rather than $STATIC arrays when possible. (which is ALWAYS!).
        Replace "large" arrays with either VIRTUAL (HUGE is not the same thing!) arrays or a random-access disk file. Consider the same for "large" strings.
        Don't use SHARED or STATIC variables unless you must.
        ERASE SHARED and STATIC arrays when done with them.
        Reset SHARED or STATIC strings to null when done with them.
        Break up application into multiple executables, main EXE + (EXE or PBC).

        Above all, don't look for a "generic will always work silver bullet solution."

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Additionally to what was already said: Read data (message strings, numbers you read into arrays, etc.) from a separate file instead of putting them into your code.

          Regards,

          Hans Ruegg

          Comment


          • #6
            Thanks for the great hints. I ended up breaking the code into smaller programs and then runing it from a batch file. Writing things to pass between the programs in a temp text file.

            Thanks Again
            Brian

            ------------------

            Comment

            Working...
            X