Microsoft KB Archive/32327

= How to CLEAR Maximum Amount of Data Space; Heap Space =

Article ID: 32327

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 1.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Interpreter 1.0
 * Microsoft BASIC Interpreter 1.01 for Macintosh
 * Microsoft BASIC Interpreter 2.0
 * Microsoft BASIC Interpreter 2.1 for Macintosh
 * Microsoft BASIC Interpreter 3.0 for Macintosh

-



This article was previously published under Q32327



SUMMARY
The CLEAR statement can be used to set the maximum amount of data space that a Macintosh BASIC program can use. This information applies to the Microsoft QuickBASIC Compiler Version 1.00, BASIC Compiler Version 1.00, and BASIC Interpreter Versions 1.00, 1.01, 2.00, 2.10, and 3.00 for Apple Macintosh.

The program below sets the maximum amount of data space that can be safely allocated given a set heap space size. The variable heap& should be set to the amount of heap space desired. About 5K serves as a minimum amount for heap space; however, because many programs using ROM routines or system resources require more heap space, it is recommended to use between 50K to 100K for such programs.



MORE INFORMATION
FRE(n), where n is any number or string (except -1 or -2), returns the number of bytes in BASIC's memory space that are not currently being used.

FRE(-1) returns the number of bytes in the Macintosh heap that are not being used by BASIC.

FRE(-2) returns the number of bytes in the stack that have never been used.

The following is a code example: k&=100  ' Set k& to the number of kilobytes (1024 bytes) of heap desired. heap&=k& * 1024& PRINT &quot;data&quot;;FRE(0);&quot;heap&quot;;FRE(-1);&quot;stack&quot;;FRE(-2)

' Subtract the desired heap size from the currently unused ' Datasize + Heapsize: max& = FRE(0) + FRE(-1) - heap& PRINT max&, heap&

' This CLEAR sets aside max& data space from the currently unused ' memory, and all other memory is taken by heap and stack: CLEAR ,max& PRINT &quot;data&quot;;FRE(0);&quot;heap&quot;;FRE(-1);&quot;stack&quot;;FRE(-2)

Additional query words: BasicCom MQuickB

Keywords: KB32327

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.