•  Back 
  •  Main 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help 
  •  Show info about hypertext 
  •  View a new file 
Topic       : The GFA-Basic Compendium
Author      : GFA Systemtechnik GmbH
Version     : GFABasic.HYP v2.98 (12/31/2023)
Subject     : Documentation/Programming
Nodes       : 899
Index Size  : 28056
HCP-Version : 3
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Document not found
@help       : Help
@options    : +g -i -s +z
@width      : 75
@hostname   : STRNGSRV
@hostname   : CAB     
@hostname   : HIGHWIRE
@hostname   : THING   
View Ref-FileFRE([x])

x: aexp

This function computes the amount of free available memory. The parameter x is
ignored, but if it is present a 'Garbage Collection' is carried out first
(non-current versions of strings are deleted and the memory occupied by them
freed). FRE() results in the free memory being calculated without the Garbage
Collection.

FRE()  - Calculate without Garbage Collection.

FRE(0) - Calculate with Garbage Collection.

Example:

    free%=FRE(0)
    max%=free%/3/4
    DIM x%(max%)
    PRINT free%,max%

--> An array is dimensioned so that it occupies for instance a third of the
    free memory space. An integer array occupies 4 bytes per element, thus the
    extra division by 4.

Memo: A compiled program should regularly force a 'Garbage Collection' to
      insure that the program does not run out of string space. There is a bug
      related to the Garbage Collection.  If the string ram drops to low
      (within 16 bytes of running out of ram) a crash can occur.

Example:

    IF FRE()<32768 !less than 32k of free ram inside our program?
      ~FRE(0)      !force garbage collection and free unused strings
    ENDIF