|
6 | 6 | assert = |
7 | 7 | 'Raises an error if the value of its argument v is false (i.e., `nil` or `false`); otherwise, returns all its arguments. In case of error, `message` is the error object; when absent, it defaults to `"assertion failed!"`' |
8 | 8 |
|
9 | | -cgopt.collect = |
10 | | -'Performs a full garbage-collection cycle.' |
11 | | -cgopt.stop = |
12 | | -'Stops automatic execution.' |
13 | | -cgopt.restart = |
14 | | -'Restarts automatic execution.' |
15 | | -cgopt.count = |
16 | | -'Returns the total memory in Kbytes.' |
17 | | -cgopt.step = |
18 | | -[[ |
19 | | -Performs a garbage-collection step. This option may be followed by an integer `size`. |
20 | | -If `size` is a positive n, the collector acts as if n new bytes have been allocated; if `size` is zero, the collector performs a basic step. |
21 | | -In incremental mode, a basic step corresponds to the current step size; in generational mode, a basic step performs a full minor collection, |
22 | | -or an incremental step if the collector has scheduled one. |
23 | | -In incremental mode, the function returns `true` if the step finished a collection cycle; in generational mode, it returns `true` if the step finished a major collection. |
24 | | -]] |
25 | | -cgopt.setpause = |
26 | | -'Set `pause`.' |
27 | | -cgopt.setstepmul = |
28 | | -'Set `step multiplier`.' |
29 | | -cgopt.incremental = |
30 | | -'Changes the collector mode to incremental and returns the previous mode (either `"generational"` or `"incremental"`).' |
31 | | -cgopt.generational = |
32 | | -'Changes the collector mode to generational and returns the previous mode (either `"generational"` or `"incremental"`).' |
33 | | -cgopt.param = |
34 | | -[[ |
35 | | -Changes and/or retrieves the values of a collector parameter. This option must be followed by one or two extra arguments: |
36 | | -the parameter name (a string) and an optional new value (an integer in the range [0,100000]). |
37 | | -The call always returns the previous value of the parameter; if no new value is given, the value is left unchanged. |
38 | | -Lua stores these values in a compressed format, so the value returned as the previous value may not be exactly the last value set. |
39 | | -]] |
40 | | - |
41 | | -gcparam.minormul = |
42 | | -'The minor multiplier.' |
43 | | -gcparam.majorminor = |
44 | | -'The major-minor multiplier.' |
45 | | -gcparam.minormajor = |
46 | | -'The minor-major multiplier.' |
47 | | -gcparam.pause = |
48 | | -'The garbage-collector pause.' |
49 | | -gcparam.stepmul = |
50 | | -'The step multiplier.' |
51 | | -gcparam.stepsize = |
52 | | -'The step size.' |
53 | | - |
54 | | -cgopt.isrunning = |
55 | | -'Returns whether the collector is running.' |
56 | | - |
57 | | -collectgarbage = |
58 | | -[[ |
59 | | -Generic interface to the garbage collector. According to the first argument `opt`, it performs: |
60 | | -• `"collect"`: Performs a full garbage-collection cycle (default option). |
61 | | -• `"stop"`: Stops automatic execution of the collector; it runs only when explicitly invoked, until `"restart"`. |
62 | | -• `"restart"`: Restarts automatic execution of the collector. |
63 | | -• `"count"`: Returns the total memory in use by Lua in Kbytes (fractional; multiply by 1024 for bytes). |
64 | | -• `"step"`: Performs a garbage-collection step; optional integer `size` controls behavior and return value (see `cgopt.step`). |
65 | | -• `"isrunning"`: Returns whether the collector is running (i.e., not stopped). |
66 | | -• `"incremental"`: Changes the mode to incremental and returns the previous mode. |
67 | | -• `"generational"`: Changes the mode to generational and returns the previous mode. |
68 | | -• `"param"`: Changes/reads collector parameters (see `gcparam.*`), always returns the previous value. |
| 9 | +collectgarbage51 = |
| 10 | +[[ |
| 11 | +This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt: |
| 12 | +
|
| 13 | +* `"collect"`: performs a full garbage-collection cycle. This is the default option. |
| 14 | +* `"stop"`: stops the garbage collector. |
| 15 | +* `"restart"`: restarts the garbage collector. |
| 16 | +* `"count"`: returns the total memory in use by Lua (in Kbytes). |
| 17 | +* `"step"`: performs a garbage-collection step. The step "size" is controlled by arg (larger values mean more steps) in a non-specified way. If you want to control the step size you must experimentally tune the value of arg. Returns true if the step finished a collection cycle. |
| 18 | +* `"setpause"`: sets arg as the new value for the pause of the collector (see §2.10). Returns the previous value for pause. |
| 19 | +* `"setstepmul"`: sets arg as the new value for the step multiplier of the collector (see §2.10). Returns the previous value for step. |
| 20 | +]] |
| 21 | + |
| 22 | +collectgarbage52 = |
| 23 | +[[ |
| 24 | +This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt: |
| 25 | +
|
| 26 | +* `"collect"`: performs a full garbage-collection cycle. This is the default option. |
| 27 | +* `"stop"`: stops automatic execution of the garbage collector. The collector will run only when explicitly invoked, until a call to restart it. |
| 28 | +* `"restart"`: restarts automatic execution of the garbage collector. |
| 29 | +* `"count"`: returns the total memory in use by Lua (in Kbytes) and a second value with the total memory in bytes modulo 1024. The first value has a fractional part, so the following equality is always true: |
| 30 | + ```lua |
| 31 | + k, b = collectgarbage("count") |
| 32 | + assert(k*1024 == math.floor(k)*1024 + b) |
| 33 | + ``` |
| 34 | + (The second result is useful when Lua is compiled with a non floating-point type for numbers.) |
| 35 | +* `"step"`: performs a garbage-collection step. The step "size" is controlled by arg (larger values mean more steps) in a non-specified way. If you want to control the step size you must experimentally tune the value of arg. Returns true if the step finished a collection cycle. |
| 36 | +* `"setpause"`: sets arg as the new value for the pause of the collector (see §2.5). Returns the previous value for pause. |
| 37 | +* `"setstepmul"`: sets arg as the new value for the step multiplier of the collector (see §2.5). Returns the previous value for step. |
| 38 | +* `"isrunning"`: returns a boolean that tells whether the collector is running (i.e., not stopped). |
| 39 | +* `"generational"`: changes the collector to generational mode. This is an experimental feature (see §2.5). |
| 40 | +* `"incremental"`: changes the collector to incremental mode. This is the default mode. |
| 41 | +]] |
| 42 | + |
| 43 | +collectgarbage53 = |
| 44 | +[[ |
| 45 | +This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt: |
| 46 | +
|
| 47 | +* `"collect"`: performs a full garbage-collection cycle. This is the default option. |
| 48 | +* `"stop"`: stops automatic execution of the garbage collector. The collector will run only when explicitly invoked, until a call to restart it. |
| 49 | +* `"restart"`: restarts automatic execution of the garbage collector. |
| 50 | +* `"count"`: returns the total memory in use by Lua in Kbytes. The value has a fractional part, so that it multiplied by 1024 gives the exact number of bytes in use by Lua (except for overflows). |
| 51 | +* `"step"`: performs a garbage-collection step. The step "size" is controlled by arg. With a zero value, the collector will perform one basic (indivisible) step. For non-zero values, the collector will perform as if that amount of memory (in KBytes) had been allocated by Lua. Returns true if the step finished a collection cycle. |
| 52 | +* `"setpause"`: sets arg as the new value for the pause of the collector (see §2.5). Returns the previous value for pause. |
| 53 | +* `"setstepmul"`: sets arg as the new value for the step multiplier of the collector (see §2.5). Returns the previous value for step. |
| 54 | +* "isrunning"`: returns a boolean that tells whether the collector is running (i.e., not stopped). |
| 55 | +]] |
| 56 | + |
| 57 | +collectgarbage54 = |
| 58 | +[[ |
| 59 | +This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt: |
| 60 | +
|
| 61 | +* `"collect"`: Performs a full garbage-collection cycle. This is the default option. |
| 62 | +* `"stop"`: Stops automatic execution of the garbage collector. The collector will run only when explicitly invoked, until a call to restart it. |
| 63 | +* `"restart"`: Restarts automatic execution of the garbage collector. |
| 64 | +* `"count"`: Returns the total memory in use by Lua in Kbytes. The value has a fractional part, so that it multiplied by 1024 gives the exact number of bytes in use by Lua. |
| 65 | +* `"step"`: Performs a garbage-collection step. The step "size" is controlled by arg. With a zero value, the collector will perform one basic (indivisible) step. For non-zero values, the collector will perform as if that amount of memory (in Kbytes) had been allocated by Lua. Returns true if the step finished a collection cycle. |
| 66 | +* `"isrunning"`: Returns a boolean that tells whether the collector is running (i.e., not stopped). |
| 67 | +* `"incremental"`: Change the collector mode to incremental. This option can be followed by three numbers: the garbage-collector pause, the step multiplier, and the step size (see §2.5.1). A zero means to not change that value. |
| 68 | +* `"generational"`: Change the collector mode to generational. This option can be followed by two numbers: the garbage-collector minor multiplier and the major multiplier (see §2.5.2). A zero means to not change that value. |
| 69 | +See §2.5 for more details about garbage collection and some of these options. |
| 70 | +
|
| 71 | +This function should not be called by a finalizer. |
| 72 | +]] |
| 73 | + |
| 74 | +collectgarbage55 = |
| 75 | +[[ |
| 76 | +This function is a generic interface to the garbage collector. It performs different functions according to its first argument, opt: |
| 77 | +
|
| 78 | +* `"collect"`: Performs a full garbage-collection cycle. This is the default option. |
| 79 | +* `"stop"`: Stops automatic execution of the garbage collector. The collector will run only when explicitly invoked, until a call to restart it. |
| 80 | +* `"restart"`: Restarts automatic execution of the garbage collector. |
| 81 | +* `"count"`: Returns the total memory in use by Lua in Kbytes. The value has a fractional part, so that it multiplied by 1024 gives the exact number of bytes in use by Lua. |
| 82 | +* `"step"`: Performs a garbage-collection step. This option may be followed by an extra argument, an integer with the step size. |
| 83 | +
|
| 84 | + If the size is a positive n, the collector acts as if n new bytes have been allocated. If the size is zero, the collector performs a basic step. In incremental mode, a basic step corresponds to the current step size. In generational mode, a basic step performs a full minor collection or an incremental step, if the collector has scheduled one. |
| 85 | +
|
| 86 | + In incremental mode, the function returns true if the step finished a collection cycle. In generational mode, the function returns true if the step finished a major collection. |
| 87 | +
|
| 88 | +* `"isrunning"`: Returns a boolean that tells whether the collector is running (i.e., not stopped). |
| 89 | +* `"incremental"`: Changes the collector mode to incremental and returns the previous mode. |
| 90 | +* `"generational"`: Changes the collector mode to generational and returns the previous mode. |
| 91 | +* `"param"`: Changes and/or retrieves the values of a parameter of the collector. This option must be followed by one or two extra arguments: The name of the parameter being changed or retrieved (a string) and an optional new value for that parameter, an integer in the range [0,100000]. The first argument must have one of the following values: |
| 92 | + * `"minormul"`: The minor multiplier. |
| 93 | + * `"majorminor"`: The major-minor multiplier. |
| 94 | + * `"minormajor"`: The minor-major multiplier. |
| 95 | + * `"pause"`: The garbage-collector pause. |
| 96 | + * `"stepmul"`: The step multiplier. |
| 97 | + * `"stepsize"`: The step size. |
| 98 | +
|
| 99 | + The call always returns the previous value of the parameter. If the call does not give a new value, the value is left unchanged. |
| 100 | +
|
| 101 | + Lua stores these values in a compressed format, so, the value returned as the previous value may not be exactly the last value set. |
| 102 | +
|
| 103 | +See §2.5 for more details about garbage collection and some of these options. |
| 104 | +
|
| 105 | +This function should not be called by a finalizer. |
69 | 106 | ]] |
70 | 107 |
|
71 | 108 | dofile = |
|
0 commit comments