Models 707B and 708B Switching Matrix Reference Manual
Section 6: Instrument programming
707B-901-01 Rev. A / August 2010
6-31
Lua does automatic memory management, which means you do not have to allocate memory for new
objects and free it when the objects are no longer needed. Lua manages memory automatically by
occasionally running a garbage collector to collect all objects that are no longer accessible from Lua.
All objects in Lua are subject to automatic management, including tables, variables, functions,
threads, and strings.
Lua uses two numbers to control its garbage-collection cycles. One number counts how many bytes
of dynamic memory Lua is using; the other is a threshold. When the number of bytes crosses the
threshold, Lua runs the garbage collector, which reclaims the memory of all inaccessible objects. The
byte counter is adjusted and the threshold is reset to twice the new value of the byte counter.
String library functions
This library provides generic functions for string manipulation, such as finding and extracting
substrings. When indexing a string in Lua, the first character is at position 1 (not 0, as in ANSI C).
Indices may be negative and are interpreted as indexing backward from the end of the string. Thus,
the last character is at position -1, and so on.