collect-garbage

action

Syntax
collect-garbage
    


Purpose

You can use the collect-garbage to force OmniMark to perform garbage collection at the most appropriate time in your program.

OmniMark performs garbage collection automatically, so the use of collect-garbage is never required. Using it indiscriminately can also increase program execution time by forcing unnecessary garbage collection. The only time that it is appropriate to call collect-garbage is in a situation where you need a particular section of code to run as fast as possible, even if that makes the rest of the program run more slowly. Typically, this will occur in a server program that spends some portion of its time idle and some part of its time processing requests. You can use collect-garbage to force OmniMark to perform garbage collection in an idle period rather than during the processing of a request. To do this, you would place collect-garbage after the processing of the request and before the end of the request loop. (Do not place it at the start of the loop or garbage collection time will be added to the request processing time.)

  process
     ; establish server
     repeat
        ; receive connection
        ; process request
        collect-garbage
     again
          

OmniMark uses the garbage collector only to manage memory for instances of records data types: collect-garbage has no effect on instances of built-in data types or those of opaque data types. If you do not use records data types in your request servicing code, there is no value to calling collect-garbage.

Related Concepts