diff options
Diffstat (limited to 'manual')
-rw-r--r-- | manual/manual.of | 134 |
1 files changed, 77 insertions, 57 deletions
diff --git a/manual/manual.of b/manual/manual.of index 263ced72..8607e57d 100644 --- a/manual/manual.of +++ b/manual/manual.of | |||
@@ -621,7 +621,8 @@ that is inaccessible from Lua. | |||
621 | another live object refer to the object.) | 621 | another live object refer to the object.) |
622 | Because Lua has no knowledge about @N{C code}, | 622 | Because Lua has no knowledge about @N{C code}, |
623 | it never collects objects accessible through the registry @see{registry}, | 623 | it never collects objects accessible through the registry @see{registry}, |
624 | which includes the global environment @see{globalenv}. | 624 | which includes the global environment @see{globalenv} and |
625 | the main thread. | ||
625 | 626 | ||
626 | 627 | ||
627 | The garbage collector (GC) in Lua can work in two modes: | 628 | The garbage collector (GC) in Lua can work in two modes: |
@@ -638,8 +639,8 @@ therefore, optimal settings are also non-portable. | |||
638 | You can change the GC mode and parameters by calling | 639 | You can change the GC mode and parameters by calling |
639 | @Lid{lua_gc} @N{in C} | 640 | @Lid{lua_gc} @N{in C} |
640 | or @Lid{collectgarbage} in Lua. | 641 | or @Lid{collectgarbage} in Lua. |
641 | You can also use these functions to control | 642 | You can also use these functions to control the collector directly, |
642 | the collector directly (e.g., to stop and restart it). | 643 | for instance to stop or restart it. |
643 | 644 | ||
644 | } | 645 | } |
645 | 646 | ||
@@ -656,39 +657,36 @@ and the @def{garbage-collector step size}. | |||
656 | 657 | ||
657 | The garbage-collector pause | 658 | The garbage-collector pause |
658 | controls how long the collector waits before starting a new cycle. | 659 | controls how long the collector waits before starting a new cycle. |
659 | The collector starts a new cycle when the use of memory | 660 | The collector starts a new cycle when the number of objects |
660 | hits @M{n%} of the use after the previous collection. | 661 | hits @M{n%} of the total after the previous collection. |
661 | Larger values make the collector less aggressive. | 662 | Larger values make the collector less aggressive. |
662 | Values equal to or less than 100 mean the collector will not wait to | 663 | Values equal to or less than 100 mean the collector will not wait to |
663 | start a new cycle. | 664 | start a new cycle. |
664 | A value of 200 means that the collector waits for the total memory in use | 665 | A value of 200 means that the collector waits for |
665 | to double before starting a new cycle. | 666 | the total number of objects to double before starting a new cycle. |
666 | The default value is 200; the maximum value is 1000. | 667 | The default value is 200; the maximum value is 1000. |
667 | 668 | ||
668 | The garbage-collector step multiplier | 669 | The garbage-collector step multiplier |
669 | controls the speed of the collector relative to | 670 | controls the speed of the collector relative to |
670 | memory allocation, | 671 | object creation, |
671 | that is, | 672 | that is, |
672 | how many elements it marks or sweeps for each | 673 | how many objects it marks or sweeps for each object created. |
673 | kilobyte of memory allocated. | 674 | Larger values make the collector more aggressive. |
674 | Larger values make the collector more aggressive but also increase | 675 | Beware that values too small can |
675 | the size of each incremental step. | 676 | make the collector too slow to ever finish a cycle. |
676 | You should not use values less than 100, | 677 | The default value is 300; the maximum value is 1000. |
677 | because they make the collector too slow and | ||
678 | can result in the collector never finishing a cycle. | ||
679 | The default value is 100; the maximum value is 1000. | ||
680 | 678 | ||
681 | The garbage-collector step size controls the | 679 | The garbage-collector step size controls the |
682 | size of each incremental step, | 680 | size of each incremental step, |
683 | specifically how many bytes the interpreter allocates | 681 | specifically how many objects the interpreter creates |
684 | before performing a step. | 682 | before performing a step. |
685 | This parameter is logarithmic: | 683 | This parameter is logarithmic: |
686 | A value of @M{n} means the interpreter will allocate @M{2@sp{n}} | 684 | A value of @M{n} means the interpreter will create @M{2@sp{n}} |
687 | bytes between steps and perform equivalent work during the step. | 685 | objects between steps and perform equivalent work during the step. |
688 | A large value (e.g., 60) makes the collector a stop-the-world | 686 | A large value (e.g., 60) makes the collector a stop-the-world |
689 | (non-incremental) collector. | 687 | (non-incremental) collector. |
690 | The default value is 13, | 688 | The default value is 8, |
691 | which means steps of approximately @N{8 Kbytes}. | 689 | which means steps of approximately @N{256 objects}. |
692 | 690 | ||
693 | } | 691 | } |
694 | 692 | ||
@@ -697,31 +695,44 @@ which means steps of approximately @N{8 Kbytes}. | |||
697 | In generational mode, | 695 | In generational mode, |
698 | the collector does frequent @emph{minor} collections, | 696 | the collector does frequent @emph{minor} collections, |
699 | which traverses only objects recently created. | 697 | which traverses only objects recently created. |
700 | If after a minor collection the use of memory is still above a limit, | 698 | If after a minor collection the number of objects is above a limit, |
701 | the collector does a stop-the-world @emph{major} collection, | 699 | the collector shifts to a @emph{major} collection, |
702 | which traverses all objects. | 700 | which traverses all objects. |
703 | The generational mode uses two parameters: | 701 | The collector will then stay doing major collections until |
704 | the @def{minor multiplier} and the @def{the major multiplier}. | 702 | it detects that the program is generating enough garbage to justify |
703 | going back to minor collections. | ||
704 | |||
705 | The generational mode uses three parameters: | ||
706 | the @def{minor multiplier}, the @def{minor-major multiplier}, | ||
707 | and the @def{major-minor multiplier}. | ||
705 | 708 | ||
706 | The minor multiplier controls the frequency of minor collections. | 709 | The minor multiplier controls the frequency of minor collections. |
707 | For a minor multiplier @M{x}, | 710 | For a minor multiplier @M{x}, |
708 | a new minor collection will be done when memory | 711 | a new minor collection will be done when the number of objects |
709 | grows @M{x%} larger than the memory in use after the previous major | 712 | grows @M{x%} larger than the number in use just after the last collection. |
710 | collection. | ||
711 | For instance, for a multiplier of 20, | 713 | For instance, for a multiplier of 20, |
712 | the collector will do a minor collection when the use of memory | 714 | the collector will do a minor collection when the number of objects |
713 | gets 20% larger than the use after the previous major collection. | 715 | gets 20% larger than the total after the last major collection. |
714 | The default value is 20; the maximum value is 200. | 716 | The default value is 20. |
715 | 717 | ||
716 | The major multiplier controls the frequency of major collections. | 718 | The minor-major multiplier controls the shift to major collections. |
717 | For a major multiplier @M{x}, | 719 | For a multiplier @M{x}, |
718 | a new major collection will be done when memory | 720 | the collector will shift to a major collection |
719 | grows @M{x%} larger than the memory in use after the previous major | 721 | when the number of old objects grows @M{x%} larger |
720 | collection. | 722 | than the total after the previous major collection. |
721 | For instance, for a multiplier of 100, | 723 | For instance, for a multiplier of 100, |
722 | the collector will do a major collection when the use of memory | 724 | the collector will do a major collection when the number of old objects |
723 | gets larger than twice the use after the previous collection. | 725 | gets larger than twice the total after the previous major collection. |
724 | The default value is 100; the maximum value is 1000. | 726 | The default value is 100. |
727 | |||
728 | The major-minor multiplier controls the shift back to minor collections. | ||
729 | For a multiplier @M{x}, | ||
730 | the collector will shift back to minor collections | ||
731 | after a major collection collects at least @M{x%} of the allocated objects. | ||
732 | In particular, for a multiplier of 0, | ||
733 | the collector will immediately shift back to minor collections | ||
734 | after doing one cycle of major collections. | ||
735 | The default value is 20. | ||
725 | 736 | ||
726 | } | 737 | } |
727 | 738 | ||
@@ -3311,9 +3322,8 @@ Returns the remainder of dividing the current amount of bytes of | |||
3311 | memory in use by Lua by 1024. | 3322 | memory in use by Lua by 1024. |
3312 | } | 3323 | } |
3313 | 3324 | ||
3314 | @item{@id{LUA_GCSTEP} @T{(int stepsize)}| | 3325 | @item{@id{LUA_GCSTEP}| |
3315 | Performs an incremental step of garbage collection, | 3326 | Performs a step of garbage collection. |
3316 | corresponding to the allocation of @id{stepsize} Kbytes. | ||
3317 | } | 3327 | } |
3318 | 3328 | ||
3319 | @item{@id{LUA_GCISRUNNING}| | 3329 | @item{@id{LUA_GCISRUNNING}| |
@@ -3321,13 +3331,13 @@ Returns a boolean that tells whether the collector is running | |||
3321 | (i.e., not stopped). | 3331 | (i.e., not stopped). |
3322 | } | 3332 | } |
3323 | 3333 | ||
3324 | @item{@id{LUA_GCINC} (int pause, int stepmul, stepsize)| | 3334 | @item{@id{LUA_GCINC} (int pause, int stepmul, int stepsize)| |
3325 | Changes the collector to incremental mode | 3335 | Changes the collector to incremental mode |
3326 | with the given parameters @see{incmode}. | 3336 | with the given parameters @see{incmode}. |
3327 | Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}). | 3337 | Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}). |
3328 | } | 3338 | } |
3329 | 3339 | ||
3330 | @item{@id{LUA_GCGEN} (int minormul, int majormul)| | 3340 | @item{@id{LUA_GCGEN} (int minormul, int minormajor, int majorminor)| |
3331 | Changes the collector to generational mode | 3341 | Changes the collector to generational mode |
3332 | with the given parameters @see{genmode}. | 3342 | with the given parameters @see{genmode}. |
3333 | Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}). | 3343 | Returns the previous mode (@id{LUA_GCGEN} or @id{LUA_GCINC}). |
@@ -6312,13 +6322,14 @@ gives the exact number of bytes in use by Lua. | |||
6312 | 6322 | ||
6313 | @item{@St{step}| | 6323 | @item{@St{step}| |
6314 | Performs a garbage-collection step. | 6324 | Performs a garbage-collection step. |
6315 | The step @Q{size} is controlled by @id{arg}. | 6325 | In incremental mode, |
6316 | With a zero value, | 6326 | that step corresponds to the current step size; |
6317 | the collector will perform one basic (indivisible) step. | 6327 | the function returns @true if the step finished a collection cycle. |
6318 | For non-zero values, | 6328 | In generational mode, |
6319 | the collector will perform as if that amount of memory | 6329 | the step performs a full minor collection or |
6320 | (in Kbytes) had been allocated by Lua. | 6330 | a major collection, |
6321 | Returns @true if the step finished a collection cycle. | 6331 | if the collector has scheduled one; |
6332 | the function returns @true if the step performed a major collection. | ||
6322 | } | 6333 | } |
6323 | 6334 | ||
6324 | @item{@St{isrunning}| | 6335 | @item{@St{isrunning}| |
@@ -6332,15 +6343,15 @@ This option can be followed by three numbers: | |||
6332 | the garbage-collector pause, | 6343 | the garbage-collector pause, |
6333 | the step multiplier, | 6344 | the step multiplier, |
6334 | and the step size @see{incmode}. | 6345 | and the step size @see{incmode}. |
6335 | A zero means to not change that value. | 6346 | A -1 or absent value means to not change that value. |
6336 | } | 6347 | } |
6337 | 6348 | ||
6338 | @item{@St{generational}| | 6349 | @item{@St{generational}| |
6339 | Change the collector mode to generational. | 6350 | Change the collector mode to generational. |
6340 | This option can be followed by two numbers: | 6351 | This option can be followed by three numbers: |
6341 | the garbage-collector minor multiplier | 6352 | the garbage-collector minor multiplier, |
6342 | and the major multiplier @see{genmode}. | 6353 | the minor-major multiplier, and the major-minor multiplier @see{genmode}. |
6343 | A zero means to not change that value. | 6354 | A -1 or absent value means to not change that value. |
6344 | } | 6355 | } |
6345 | 6356 | ||
6346 | } | 6357 | } |
@@ -9229,6 +9240,9 @@ declare a local variable with the same name in the loop body. | |||
9229 | @itemize{ | 9240 | @itemize{ |
9230 | 9241 | ||
9231 | @item{ | 9242 | @item{ |
9243 | There were several changes in the parameters | ||
9244 | for the options @St{incremental} and @St{generational} | ||
9245 | of the function @Lid{collectgarbage}. | ||
9232 | } | 9246 | } |
9233 | 9247 | ||
9234 | } | 9248 | } |
@@ -9245,6 +9259,12 @@ it is equivalent to @Lid{lua_closethread} with | |||
9245 | @id{from} being @id{NULL}. | 9259 | @id{from} being @id{NULL}. |
9246 | } | 9260 | } |
9247 | 9261 | ||
9262 | @item{ | ||
9263 | There were several changes in the parameters | ||
9264 | for the options @Lid{LUA_GCINC} and @Lid{LUA_GCGEN} | ||
9265 | of the function @Lid{lua_gc}. | ||
9266 | } | ||
9267 | |||
9248 | } | 9268 | } |
9249 | 9269 | ||
9250 | } | 9270 | } |