summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--manual/manual.of115
1 files changed, 62 insertions, 53 deletions
diff --git a/manual/manual.of b/manual/manual.of
index 2c0957b9..fd49b404 100644
--- a/manual/manual.of
+++ b/manual/manual.of
@@ -575,7 +575,7 @@ or @Lid{collectgarbage} in Lua.
575You can also use these functions to control 575You can also use these functions to control
576the collector directly (e.g., to stop and restart it). 576the collector directly (e.g., to stop and restart it).
577 577
578@sect3{@title{Incremental Garbage Collection} 578@sect3{incmode| @title{Incremental Garbage Collection}
579 579
580In incremental mode, 580In incremental mode,
581each GC cycle performs a mark-and-sweep collection in small steps 581each GC cycle performs a mark-and-sweep collection in small steps
@@ -624,7 +624,7 @@ which means steps of approximately @N{8 Kbytes}.
624 624
625} 625}
626 626
627@sect3{@title{Generational Garbage Collection} 627@sect3{genmode| @title{Generational Garbage Collection}
628 628
629In generational mode, 629In generational mode,
630the collector does frequent @emph{minor} collections, 630the collector does frequent @emph{minor} collections,
@@ -633,17 +633,7 @@ If after a minor collection the use of memory is still above a limit,
633the collector does a @emph{major} collection, 633the collector does a @emph{major} collection,
634which traverses all objects. 634which traverses all objects.
635The generational mode uses two parameters: 635The generational mode uses two parameters:
636the @def{major multiplier} and the @def{the minor multiplier}. 636the @def{minor multiplier} and the @def{the major multiplier}.
637
638The major multiplier controls the frequency of major collections.
639For a major multiplier @M{x},
640a new major collection will be done when memory
641grows @M{x%} larger than the memory in use after the previous major
642collection.
643For instance, for a multiplier of 100,
644the collector will do a major collection when the use of memory
645gets larger than twice the use after the previous collection.
646The default value is 100; the maximum value is 1000.
647 637
648The minor multiplier controls the frequency of minor collections. 638The minor multiplier controls the frequency of minor collections.
649For a minor multiplier @M{x}, 639For a minor multiplier @M{x},
@@ -655,6 +645,16 @@ the collector will do a minor collection when the use of memory
655gets 20% larger than the use after the previous major collection. 645gets 20% larger than the use after the previous major collection.
656The default value is 20; the maximum value is 200. 646The default value is 20; the maximum value is 200.
657 647
648The major multiplier controls the frequency of major collections.
649For a major multiplier @M{x},
650a new major collection will be done when memory
651grows @M{x%} larger than the memory in use after the previous major
652collection.
653For instance, for a multiplier of 100,
654the collector will do a major collection when the use of memory
655gets larger than twice the use after the previous collection.
656The default value is 100; the maximum value is 1000.
657
658} 658}
659 659
660@sect3{finalizers| @title{Garbage-Collection Metamethods} 660@sect3{finalizers| @title{Garbage-Collection Metamethods}
@@ -3022,55 +3022,58 @@ and therefore never returns
3022 3022
3023} 3023}
3024 3024
3025@APIEntry{int lua_gc (lua_State *L, int what, int data);| 3025@APIEntry{int lua_gc (lua_State *L, int what, ...);|
3026@apii{0,0,-} 3026@apii{0,0,-}
3027 3027
3028Controls the garbage collector. 3028Controls the garbage collector.
3029 3029
3030This function performs several tasks, 3030This function performs several tasks,
3031according to the value of the parameter @id{what}: 3031according to the value of the parameter @id{what}.
3032For options that need extra arguments,
3033they are listed after the option.
3032@description{ 3034@description{
3033 3035
3034@item{@id{LUA_GCSTOP}| 3036@item{@id{LUA_GCCOLLECT}|
3035stops the garbage collector. 3037Performs a full garbage-collection cycle.
3036} 3038}
3037 3039
3038@item{@id{LUA_GCRESTART}| 3040@item{@id{LUA_GCSTOP}|
3039restarts the garbage collector. 3041Stops the garbage collector.
3040} 3042}
3041 3043
3042@item{@id{LUA_GCCOLLECT}| 3044@item{@id{LUA_GCRESTART}|
3043performs a full garbage-collection cycle. 3045Restarts the garbage collector.
3044} 3046}
3045 3047
3046@item{@id{LUA_GCCOUNT}| 3048@item{@id{LUA_GCCOUNT}|
3047returns the current amount of memory (in Kbytes) in use by Lua. 3049Returns the current amount of memory (in Kbytes) in use by Lua.
3048} 3050}
3049 3051
3050@item{@id{LUA_GCCOUNTB}| 3052@item{@id{LUA_GCCOUNTB}|
3051returns the remainder of dividing the current amount of bytes of 3053Returns the remainder of dividing the current amount of bytes of
3052memory in use by Lua by 1024. 3054memory in use by Lua by 1024.
3053} 3055}
3054 3056
3055@item{@id{LUA_GCSTEP}| 3057@item{@id{LUA_GCSTEP} @T{(int stepsize)}|
3056performs an incremental step of garbage collection. 3058Performs an incremental step of garbage collection,
3059corresponding to the allocation of @id{stepsize} Kbytes.
3057} 3060}
3058 3061
3059@item{@id{LUA_GCSETPAUSE}| 3062@item{@id{LUA_GCISRUNNING}|
3060sets @id{data} as the new value 3063Returns a boolean that tells whether the collector is running
3061for the @emph{pause} of the collector @see{GC} 3064(i.e., not stopped).
3062and returns the previous value of the pause.
3063} 3065}
3064 3066
3065@item{@id{LUA_GCSETSTEPMUL}| 3067@item{@id{LUA_GCINC} (int pause, int stepmul, stepsize)|
3066sets @id{data} as the new value for the @emph{step multiplier} of 3068Changes the collector to incremental mode
3067the collector @see{GC} 3069with the given parameters @see{incmode}.
3068and returns the previous value of the step multiplier. 3070Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}).
3069} 3071}
3070 3072
3071@item{@id{LUA_GCISRUNNING}| 3073@item{@id{LUA_GCGEN} (int minormul, int majormul)|
3072returns a boolean that tells whether the collector is running 3074Changes the collector to generational mode
3073(i.e., not stopped). 3075with the given parameters @see{genmode}.
3076Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}).
3074} 3077}
3075 3078
3076} 3079}
@@ -5949,42 +5952,41 @@ It performs different functions according to its first argument, @id{opt}:
5949@description{ 5952@description{
5950 5953
5951@item{@St{collect}| 5954@item{@St{collect}|
5952performs a full garbage-collection cycle. 5955Performs a full garbage-collection cycle.
5953This is the default option. 5956This is the default option.
5954} 5957}
5955 5958
5956@item{@St{stop}| 5959@item{@St{stop}|
5957stops automatic execution of the garbage collector. 5960Stops automatic execution of the garbage collector.
5958The collector will run only when explicitly invoked, 5961The collector will run only when explicitly invoked,
5959until a call to restart it. 5962until a call to restart it.
5960} 5963}
5961 5964
5962@item{@St{restart}| 5965@item{@St{restart}|
5963restarts automatic execution of the garbage collector. 5966Restarts automatic execution of the garbage collector.
5964} 5967}
5965 5968
5966@item{@St{count}| 5969@item{@St{count}|
5967returns the total memory in use by Lua in Kbytes. 5970Returns the total memory in use by Lua in Kbytes.
5968The value has a fractional part, 5971The value has a fractional part,
5969so that it multiplied by 1024 5972so that it multiplied by 1024
5970gives the exact number of bytes in use by Lua. 5973gives the exact number of bytes in use by Lua.
5971} 5974}
5972 5975
5973@item{@St{step}| 5976@item{@St{step}|
5974performs a garbage-collection step. 5977Performs a garbage-collection step.
5975The step @Q{size} is controlled by @id{arg}. 5978The step @Q{size} is controlled by @id{arg}.
5976With a zero value, 5979With a zero value,
5977the collector will perform one basic (indivisible) step. 5980the collector will perform one basic (indivisible) step.
5978For non-zero values, 5981For non-zero values,
5979the collector will perform as if that amount of memory 5982the collector will perform as if that amount of memory
5980(in KBytes) had been allocated by Lua. 5983(in Kbytes) had been allocated by Lua.
5981Returns @true if the step finished a collection cycle. 5984Returns @true if the step finished a collection cycle.
5982} 5985}
5983 5986
5984@item{@St{setpause}| 5987@item{@St{isrunning}|
5985sets @id{arg} as the new value for the @emph{pause} of 5988Returns a boolean that tells whether the collector is running
5986the collector @see{GC}. 5989(i.e., not stopped).
5987Returns the previous value for @emph{pause}.
5988} 5990}
5989 5991
5990@item{@St{incremental}| 5992@item{@St{incremental}|
@@ -5992,7 +5994,7 @@ Change the collector mode to incremental.
5992This option can be followed by three numbers: 5994This option can be followed by three numbers:
5993the garbage-collector pause, 5995the garbage-collector pause,
5994the step multiplier, 5996the step multiplier,
5995and the step size. 5997and the step size @see{incmode}.
5996A zero means to not change that value. 5998A zero means to not change that value.
5997} 5999}
5998 6000
@@ -6000,15 +6002,10 @@ A zero means to not change that value.
6000Change the collector mode to generational. 6002Change the collector mode to generational.
6001This option can be followed by two numbers: 6003This option can be followed by two numbers:
6002the garbage-collector minor multiplier 6004the garbage-collector minor multiplier
6003and the major multiplier. 6005and the major multiplier @see{genmode}.
6004A zero means to not change that value. 6006A zero means to not change that value.
6005} 6007}
6006 6008
6007@item{@St{isrunning}|
6008returns a boolean that tells whether the collector is running
6009(i.e., not stopped).
6010}
6011
6012} 6009}
6013See @See{GC} for more details about garbage collection 6010See @See{GC} for more details about garbage collection
6014and some of these options. 6011and some of these options.
@@ -8880,6 +8877,12 @@ do not accept surrogates as valid code points.
8880An extra parameter in these functions makes them more permissive. 8877An extra parameter in these functions makes them more permissive.
8881} 8878}
8882 8879
8880@item{
8881The options @St{setpause} and @St{setstepmul}
8882of the function @Lid{collectgarbage} are deprecated.
8883You should use the new option @St{incremental} to set them.
8884}
8885
8883} 8886}
8884 8887
8885} 8888}
@@ -8925,6 +8928,12 @@ Errors in finalizers are never propagated;
8925instead, they generate a warning. 8928instead, they generate a warning.
8926} 8929}
8927 8930
8931@item{
8932The options @idx{LUA_GCSETPAUSE} and @idx{LUA_GCSETSTEPMUL}
8933of the function @Lid{lua_gc} are deprecated.
8934You should use the new option @id{LUA_GCINC} to set them.
8935}
8936
8928} 8937}
8929 8938
8930} 8939}