Skip to content

Commit f39e8c0

Browse files
committed
Updated the documentation for the API function 'lua_gc'
1 parent 6aeaeb5 commit f39e8c0

File tree

1 file changed

+62
-53
lines changed

1 file changed

+62
-53
lines changed

manual/manual.of

Lines changed: 62 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ or @Lid{collectgarbage} in Lua.
575575
You can also use these functions to control
576576
the collector directly (e.g., to stop and restart it).
577577

578-
@sect3{@title{Incremental Garbage Collection}
578+
@sect3{incmode| @title{Incremental Garbage Collection}
579579

580580
In incremental mode,
581581
each GC cycle performs a mark-and-sweep collection in small steps
@@ -624,7 +624,7 @@ which means steps of approximately @N{8 Kbytes}.
624624

625625
}
626626

627-
@sect3{@title{Generational Garbage Collection}
627+
@sect3{genmode| @title{Generational Garbage Collection}
628628

629629
In generational mode,
630630
the collector does frequent @emph{minor} collections,
@@ -633,17 +633,7 @@ If after a minor collection the use of memory is still above a limit,
633633
the collector does a @emph{major} collection,
634634
which traverses all objects.
635635
The generational mode uses two parameters:
636-
the @def{major multiplier} and the @def{the minor multiplier}.
637-
638-
The major multiplier controls the frequency of major collections.
639-
For a major multiplier @M{x},
640-
a new major collection will be done when memory
641-
grows @M{x%} larger than the memory in use after the previous major
642-
collection.
643-
For instance, for a multiplier of 100,
644-
the collector will do a major collection when the use of memory
645-
gets larger than twice the use after the previous collection.
646-
The default value is 100; the maximum value is 1000.
636+
the @def{minor multiplier} and the @def{the major multiplier}.
647637

648638
The minor multiplier controls the frequency of minor collections.
649639
For a minor multiplier @M{x},
@@ -655,6 +645,16 @@ the collector will do a minor collection when the use of memory
655645
gets 20% larger than the use after the previous major collection.
656646
The default value is 20; the maximum value is 200.
657647

648+
The major multiplier controls the frequency of major collections.
649+
For a major multiplier @M{x},
650+
a new major collection will be done when memory
651+
grows @M{x%} larger than the memory in use after the previous major
652+
collection.
653+
For instance, for a multiplier of 100,
654+
the collector will do a major collection when the use of memory
655+
gets larger than twice the use after the previous collection.
656+
The default value is 100; the maximum value is 1000.
657+
658658
}
659659

660660
@sect3{finalizers| @title{Garbage-Collection Metamethods}
@@ -3022,55 +3022,58 @@ and therefore never returns
30223022

30233023
}
30243024

3025-
@APIEntry{int lua_gc (lua_State *L, int what, int data);|
3025+
@APIEntry{int lua_gc (lua_State *L, int what, ...);|
30263026
@apii{0,0,-}
30273027

30283028
Controls the garbage collector.
30293029

30303030
This function performs several tasks,
3031-
according to the value of the parameter @id{what}:
3031+
according to the value of the parameter @id{what}.
3032+
For options that need extra arguments,
3033+
they are listed after the option.
30323034
@description{
30333035

3034-
@item{@id{LUA_GCSTOP}|
3035-
stops the garbage collector.
3036+
@item{@id{LUA_GCCOLLECT}|
3037+
Performs a full garbage-collection cycle.
30363038
}
30373039

3038-
@item{@id{LUA_GCRESTART}|
3039-
restarts the garbage collector.
3040+
@item{@id{LUA_GCSTOP}|
3041+
Stops the garbage collector.
30403042
}
30413043

3042-
@item{@id{LUA_GCCOLLECT}|
3043-
performs a full garbage-collection cycle.
3044+
@item{@id{LUA_GCRESTART}|
3045+
Restarts the garbage collector.
30443046
}
30453047

30463048
@item{@id{LUA_GCCOUNT}|
3047-
returns the current amount of memory (in Kbytes) in use by Lua.
3049+
Returns the current amount of memory (in Kbytes) in use by Lua.
30483050
}
30493051

30503052
@item{@id{LUA_GCCOUNTB}|
3051-
returns the remainder of dividing the current amount of bytes of
3053+
Returns the remainder of dividing the current amount of bytes of
30523054
memory in use by Lua by 1024.
30533055
}
30543056

3055-
@item{@id{LUA_GCSTEP}|
3056-
performs an incremental step of garbage collection.
3057+
@item{@id{LUA_GCSTEP} @T{(int stepsize)}|
3058+
Performs an incremental step of garbage collection,
3059+
corresponding to the allocation of @id{stepsize} Kbytes.
30573060
}
30583061

3059-
@item{@id{LUA_GCSETPAUSE}|
3060-
sets @id{data} as the new value
3061-
for the @emph{pause} of the collector @see{GC}
3062-
and returns the previous value of the pause.
3062+
@item{@id{LUA_GCISRUNNING}|
3063+
Returns a boolean that tells whether the collector is running
3064+
(i.e., not stopped).
30633065
}
30643066

3065-
@item{@id{LUA_GCSETSTEPMUL}|
3066-
sets @id{data} as the new value for the @emph{step multiplier} of
3067-
the collector @see{GC}
3068-
and returns the previous value of the step multiplier.
3067+
@item{@id{LUA_GCINC} (int pause, int stepmul, stepsize)|
3068+
Changes the collector to incremental mode
3069+
with the given parameters @see{incmode}.
3070+
Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}).
30693071
}
30703072

3071-
@item{@id{LUA_GCISRUNNING}|
3072-
returns a boolean that tells whether the collector is running
3073-
(i.e., not stopped).
3073+
@item{@id{LUA_GCGEN} (int minormul, int majormul)|
3074+
Changes the collector to generational mode
3075+
with the given parameters @see{genmode}.
3076+
Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}).
30743077
}
30753078

30763079
}
@@ -5949,66 +5952,60 @@ It performs different functions according to its first argument, @id{opt}:
59495952
@description{
59505953

59515954
@item{@St{collect}|
5952-
performs a full garbage-collection cycle.
5955+
Performs a full garbage-collection cycle.
59535956
This is the default option.
59545957
}
59555958

59565959
@item{@St{stop}|
5957-
stops automatic execution of the garbage collector.
5960+
Stops automatic execution of the garbage collector.
59585961
The collector will run only when explicitly invoked,
59595962
until a call to restart it.
59605963
}
59615964

59625965
@item{@St{restart}|
5963-
restarts automatic execution of the garbage collector.
5966+
Restarts automatic execution of the garbage collector.
59645967
}
59655968

59665969
@item{@St{count}|
5967-
returns the total memory in use by Lua in Kbytes.
5970+
Returns the total memory in use by Lua in Kbytes.
59685971
The value has a fractional part,
59695972
so that it multiplied by 1024
59705973
gives the exact number of bytes in use by Lua.
59715974
}
59725975

59735976
@item{@St{step}|
5974-
performs a garbage-collection step.
5977+
Performs a garbage-collection step.
59755978
The step @Q{size} is controlled by @id{arg}.
59765979
With a zero value,
59775980
the collector will perform one basic (indivisible) step.
59785981
For non-zero values,
59795982
the 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.
59815984
Returns @true if the step finished a collection cycle.
59825985
}
59835986

5984-
@item{@St{setpause}|
5985-
sets @id{arg} as the new value for the @emph{pause} of
5986-
the collector @see{GC}.
5987-
Returns the previous value for @emph{pause}.
5987+
@item{@St{isrunning}|
5988+
Returns a boolean that tells whether the collector is running
5989+
(i.e., not stopped).
59885990
}
59895991

59905992
@item{@St{incremental}|
59915993
Change the collector mode to incremental.
59925994
This option can be followed by three numbers:
59935995
the garbage-collector pause,
59945996
the step multiplier,
5995-
and the step size.
5997+
and the step size @see{incmode}.
59965998
A zero means to not change that value.
59975999
}
59986000

59996001
@item{@St{generational}|
60006002
Change the collector mode to generational.
60016003
This option can be followed by two numbers:
60026004
the garbage-collector minor multiplier
6003-
and the major multiplier.
6005+
and the major multiplier @see{genmode}.
60046006
A zero means to not change that value.
60056007
}
60066008

6007-
@item{@St{isrunning}|
6008-
returns a boolean that tells whether the collector is running
6009-
(i.e., not stopped).
6010-
}
6011-
60126009
}
60136010
See @See{GC} for more details about garbage collection
60146011
and some of these options.
@@ -8880,6 +8877,12 @@ do not accept surrogates as valid code points.
88808877
An extra parameter in these functions makes them more permissive.
88818878
}
88828879

8880+
@item{
8881+
The options @St{setpause} and @St{setstepmul}
8882+
of the function @Lid{collectgarbage} are deprecated.
8883+
You should use the new option @St{incremental} to set them.
8884+
}
8885+
88838886
}
88848887

88858888
}
@@ -8925,6 +8928,12 @@ Errors in finalizers are never propagated;
89258928
instead, they generate a warning.
89268929
}
89278930

8931+
@item{
8932+
The options @idx{LUA_GCSETPAUSE} and @idx{LUA_GCSETSTEPMUL}
8933+
of the function @Lid{lua_gc} are deprecated.
8934+
You should use the new option @id{LUA_GCINC} to set them.
8935+
}
8936+
89288937
}
89298938

89308939
}

0 commit comments

Comments
 (0)