Explanation of String Space Garbage Collection; FRE Function (12337)



The information in this article applies to:

  • Microsoft QuickBASIC 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBASIC 4.5
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0
  • Microsoft BASIC Compiler for MS-DOS and OS/2 6.0b
  • Microsoft Basic Professional Development System (PDS) for MS-DOS and MS OS/2 7.0

This article was previously published under Q12337

SUMMARY

This article discusses three topics regarding string space compression:

  1. When QuickBasic compresses string space during execution of a program
  2. Whether disabling string space compression is possible
  3. Whether string descriptors are fixed in memory or if they move

MORE INFORMATION

  1. When a string variable is assigned a new value, the new string takes the next available memory in string space. The old string value is deallocated but takes up space until string space "garbage collection" occurs.

    A program compresses string space as part of "garbage collection" when deallocated strings fill up the 60,000 bytes of available data space and the program needs to reallocate a string variable or a temporary string variable. You can force string compression with the FRE function [PRINT FRE("")], but there is no other way to predict when it will occur. An OPEN or CLOSE of a file can also trigger garbage collection.
  2. There is no way to disable the automatic garbage collection. At the time garbage collection occurs, your program is out of memory, so that if you were to disable it, your program could not continue to execute.

    You can schedule garbage collection to some extent by using the FRE function before executing code where you do not want garbage collection to occur, but if memory is tight, garbage collection may occur again anyway.
  3. String descriptors are the first bytes of each string, and they move as the strings move.

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:KB12337