diff options
author | brainfvck <li.zekun@gmail.com> | 2017-10-16 19:49:41 (GMT) |
---|---|---|
committer | Ćukasz Langa <lukasz@langa.pl> | 2017-10-16 19:49:41 (GMT) |
commit | c75edabbb65ca2bb29e51f8d1eb2c780e5890982 (patch) | |
tree | e437dc1926002cf3700c39696ec239da3f31dc1e /Doc/library/gc.rst | |
parent | bdaeb7d237462a629e6c85001317faa85f94a0c6 (diff) | |
download | cpython-c75edabbb65ca2bb29e51f8d1eb2c780e5890982.zip cpython-c75edabbb65ca2bb29e51f8d1eb2c780e5890982.tar.gz cpython-c75edabbb65ca2bb29e51f8d1eb2c780e5890982.tar.bz2 |
bpo-31558: Add gc.freeze() (#3705)
Freeze all the objects tracked by gc - move them to a permanent generation
and ignore all the future collections. This can be used before a POSIX
fork() call to make the gc copy-on-write friendly or to speed up collection.
Diffstat (limited to 'Doc/library/gc.rst')
-rw-r--r-- | Doc/library/gc.rst | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Doc/library/gc.rst b/Doc/library/gc.rst index 87d6824..153d8fb 100644 --- a/Doc/library/gc.rst +++ b/Doc/library/gc.rst @@ -174,6 +174,33 @@ The :mod:`gc` module provides the following functions: .. versionadded:: 3.1 +.. function:: freeze() + + Freeze all the objects tracked by gc - move them to a permanent generation + and ignore all the future collections. This can be used before a POSIX + fork() call to make the gc copy-on-write friendly or to speed up collection. + Also collection before a POSIX fork() call may free pages for future + allocation which can cause copy-on-write too so it's advised to disable gc + in master process and freeze before fork and enable gc in child process. + + .. versionadded:: 3.7 + + +.. function:: unfreeze() + + Unfreeze the objects in the permanent generation, put them back into the + oldest generation. + + .. versionadded:: 3.7 + + +.. function:: get_freeze_count() + + Return the number of objects in the permanent generation. + + .. versionadded:: 3.7 + + The following variables are provided for read-only access (you can mutate the values but should not rebind them): |