summaryrefslogtreecommitdiffstats
path: root/Modules/gcmodule.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-36389: Cleanup gc.set_threshold() (GH-12844)Victor Stinner2019-04-151-2/+2
| | | | Don't assign generations[2].threshold to generations[2].threshold: useless operation.
* bpo-36016: Add generation option to gc.getobjects() (GH-11909)Pablo Galindo2019-02-231-5/+39
|
* bpo-35059: Cast void* to PyObject* (GH-10650)Victor Stinner2018-11-221-4/+5
| | | Don't pass void* to Python macros: use _PyObject_CAST().
* bpo-35059: Convert _PyObject_GC_TRACK() to inline function (GH-10643)Victor Stinner2018-11-221-6/+7
| | | | | | | | | | | | | * Add _PyObject_ASSERT_FROM() and _PyObject_ASSERT_FAILED_MSG() macros. * PyObject_GC_Track() now calls _PyObject_ASSERT_FAILED_MSG(), instead of Py_FatalError(), if the object is already tracked, to dump more information on error. * _PyObject_GC_TRACK() no longer checks if the object is already tracked at runtime, use an assertion instead for best performances; PyObject_GC_Track() still checks at runtime. * pycore_object.h now includes pycore_pystate.h. * Convert _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() macros to inline functions.
* bpo-35081: Add Include/internal/pycore_object.h (GH-10640)Victor Stinner2018-11-211-0/+1
| | | | Move _PyObject_GC_TRACK() and _PyObject_GC_UNTRACK() from Include/objimpl.h to Include/internal/pycore_object.h.
* bpo-35081: Rename internal headers (GH-10275)Victor Stinner2018-11-121-2/+2
| | | | | | | | | | | | | | Rename Include/internal/ headers: * pycore_hash.h -> pycore_pyhash.h * pycore_lifecycle.h -> pycore_pylifecycle.h * pycore_mem.h -> pycore_pymem.h * pycore_state.h -> pycore_pystate.h Add missing headers to Makefile.pre.in and PCbuild: * pycore_condvar.h. * pycore_hamt.h * pycore_pyhash.h
* bpo-35081: Add pycore_ prefix to internal header files (GH-10263)Victor Stinner2018-10-311-3/+3
| | | | | | | | | | | | | | | | | | | | * Rename Include/internal/ header files: * pyatomic.h -> pycore_atomic.h * ceval.h -> pycore_ceval.h * condvar.h -> pycore_condvar.h * context.h -> pycore_context.h * pygetopt.h -> pycore_getopt.h * gil.h -> pycore_gil.h * hamt.h -> pycore_hamt.h * hash.h -> pycore_hash.h * mem.h -> pycore_mem.h * pystate.h -> pycore_state.h * warnings.h -> pycore_warnings.h * PCbuild project, Makefile.pre.in, Modules/Setup: add the Include/internal/ directory to the search paths of header files. * Update includes. For example, replace #include "internal/mem.h" with #include "pycore_mem.h".
* bpo-9263: Use _PyObject_ASSERT() in gcmodule.c (GH-10112)Victor Stinner2018-10-261-46/+56
| | | | | | | | | | Replace assert() with _PyObject_ASSERT() in Modules/gcmodule.c to dump the faulty object on assertion failure to ease debugging. Fix also indentation of a large comment. Initial patch written by David Malcolm. Co-Authored-By: David Malcolm <dmalcolm@redhat.com>
* bpo-9263: Dump Python object on GC assertion failure (GH-10062)Victor Stinner2018-10-251-7/+9
| | | | | | | | | | | | | | | | | | | | | | | Changes: * Add _PyObject_AssertFailed() function. * Add _PyObject_ASSERT() and _PyObject_ASSERT_WITH_MSG() macros. * gc_decref(): replace assert() with _PyObject_ASSERT_WITH_MSG() to dump the faulty object if the assertion fails. _PyObject_AssertFailed() calls: * _PyMem_DumpTraceback(): try to log the traceback where the object memory has been allocated if tracemalloc is enabled. * _PyObject_Dump(): log repr(obj). * Py_FatalError(): log the current Python traceback. _PyObject_AssertFailed() uses _PyObject_IsFreed() heuristic to check if the object memory has been freed by a debug hook on Python memory allocators. Initial patch written by David Malcolm. Co-Authored-By: David Malcolm <dmalcolm@redhat.com>
* Fix typos in comments (GH-9905)Quan Tian2018-10-191-1/+1
|
* bpo-33597: Reduce PyGC_Head size (GH-7043)INADA Naoki2018-07-101-210/+369
|
* bpo-33622: Add checks for exceptions leaks in the garbage collector. (GH-7126)Serhiy Storchaka2018-05-291-4/+23
| | | | | * Failure in adding to gc.garbage is no longer fatal. * An exception in tp_clear() no longer lead to crash (though tp_clear() should not leave exceptions).
* bpo-33622: Fix issues with handling errors in the GC. (GH-7078)Serhiy Storchaka2018-05-241-8/+11
| | | | | | | * Fixed a leak when the GC fails to add an object with __del__ into the gc.garbage list. * PyGC_Collect() can now be called when an exception is set and preserves it. * Fixed an undefined behavior with comparing a dead pointer with NULL.
* bpo-33583: Add note in PyObject_GC_Resize() doc (GH-7021)INADA Naoki2018-05-211-0/+1
|
* Revert "bpo-31356: Add context manager to temporarily disable GC GH-5495Yury Selivanov2018-02-021-106/+0
| | | | | | | This reverts commit 72a0d218dcc94a3cc409a9ef32dfcd5a7bbcb43c. The reverted commit had a few issues so it was unanimously decided to undo it. See the bpo issue for details.
* bpo-31356: Add context manager to temporarily disable GC (GH-4224)Pablo Galindo2018-01-291-0/+106
|
* bpo-32436: Implement PEP 567 (#5027)Yury Selivanov2018-01-231-0/+2
|
* bpo-9566: Fix size_t=>int downcast warnings (#5230)Victor Stinner2018-01-181-3/+3
| | | | * Use wider types (int => Py_ssize_t) to avoid integer overflows. * Fix gc.get_freeze_count(): use Py_ssize_t type rather than int, since gc_list_size() returns a Py_ssize_t.
* Add the const qualifier to "char *" variables that refer to literal strings. ↵Serhiy Storchaka2017-11-111-1/+1
| | | | (#4370)
* bpo-31558: Add gc.freeze() (#3705)brainfvck2017-10-161-1/+63
| | | | | 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.
* bpo-30860: Consolidate stateful runtime globals. (#3397)Eric Snow2017-09-081-213/+98
| | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* Revert "bpo-30860: Consolidate stateful runtime globals." (#3379)Eric Snow2017-09-061-96/+213
| | | Windows buildbots started failing due to include-related errors.
* bpo-30860: Consolidate stateful runtime globals. (#2594)Eric Snow2017-09-061-213/+96
| | | | | | | | | * group the (stateful) runtime globals into various topical structs * consolidate the topical structs under a single top-level _PyRuntimeState struct * add a check-c-globals.py script that helps identify runtime globals Other globals are excluded (see globals.txt and check-c-globals.py).
* Issue #20185: Converted the gc module to Argument Clinic.Serhiy Storchaka2017-02-041-98/+132
|
* Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE whereverSerhiy Storchaka2017-01-231-8/+4
| | | | possible. Patch is writen with Coccinelle.
* Backed out changeset b9c9691c72c5Victor Stinner2016-12-041-1/+1
| | | | | | Issue #28858: The change b9c9691c72c5 introduced a regression. It seems like _PyObject_CallArg1() uses more stack memory than PyObject_CallFunctionObjArgs().
* Replace PyObject_CallFunctionObjArgs() with fastcallVictor Stinner2016-12-011-1/+1
| | | | | | | | | | | | | | * PyObject_CallFunctionObjArgs(func, NULL) => _PyObject_CallNoArg(func) * PyObject_CallFunctionObjArgs(func, arg, NULL) => _PyObject_CallArg1(func, arg) PyObject_CallFunctionObjArgs() allocates 40 bytes on the C stack and requires extra work to "parse" C arguments to build a C array of PyObject*. _PyObject_CallNoArg() and _PyObject_CallArg1() are simpler and don't allocate memory on the C stack. This change is part of the fastcall project. The change on listsort() is related to the issue #23507.
* Don't run garbage collection on interpreter exit if it was explicitly disabledŁukasz Langa2016-09-101-0/+9
| | | | by the user.
* DTrace support: function calls, GC activity, line executionŁukasz Langa2016-09-101-0/+8
| | | | | | | | | | | | | | | | | | | Tested on macOS 10.11 dtrace, Ubuntu 16.04 SystemTap, and libbcc. Largely based by an initial patch by Jesús Cea Avión, with some influence from Dave Malcolm's SystemTap patch and Nikhil Benesch's unification patch. Things deliberately left out for simplicity: - ustack helpers, I have no way of testing them at this point since they are Solaris-specific - PyFrameObject * in function__entry/function__return, this is SystemTap-specific - SPARC support - dynamic tracing - sys module dtrace facility introspection All of those might be added later.
* Issue #28003: Implement PEP 525 -- Asynchronous Generators.Yury Selivanov2016-09-091-0/+1
|
* Issue #25923: Added more const qualifiers to signatures of static and ↵Serhiy Storchaka2015-12-251-1/+1
| | | | private functions.
* Issue #22117: The gc module now uses _PyTime_t timestampVictor Stinner2015-03-271-6/+6
|
* Issue #22043: time.monotonic() is now always availableVictor Stinner2014-09-021-3/+3
| | | | | threading.Lock.acquire(), threading.RLock.acquire() and socket operations now use a monotonic clock, instead of the system clock, when a timeout is used.
* Cleanup other stats formatting code in gcmodule.cAntoine Pitrou2014-05-241-5/+3
|
* Issue #21555: simplify code in gcmodule.c by using the pytime.h functions ↵Antoine Pitrou2014-05-241-41/+9
| | | | | | instead of trying to call time.time() via the C API. Patch by Geoffrey Spear.
* Merge from 3.4.Tim Peters2014-05-081-11/+23
|\ | | | | | | | | | | Issue #21435: Segfault in gc with cyclic trash Changed the iteration logic in finalize_garbage() to tolerate objects vanishing from the list as a side effect of executing a finalizer.
| * Issue #21435: Segfault in gc with cyclic trashTim Peters2014-05-081-11/+23
| | | | | | | | | | Changed the iteration logic in finalize_garbage() to tolerate objects vanishing from the list as a side effect of executing a finalizer.
* | Issue #21233: Add new C functions: PyMem_RawCalloc(), PyMem_Calloc(),Victor Stinner2014-05-021-4/+20
|/ | | | | | PyObject_Calloc(), _PyObject_GC_Calloc(). bytes(int) and bytearray(int) are now using ``calloc()`` instead of ``malloc()`` for large objects which is faster and use less memory (until the bytearray buffer is filled with data).
* Issue #20315: Removed support for backward compatibility with early 2.x ↵Serhiy Storchaka2014-01-201-14/+0
|\ | | | | | | | | | | | | versions. Removed backward compatibility alias curses.window.nooutrefresh which should be removed in 2.3.
| * Issue #20315: Removed support for backward compatibility with early 2.x ↵Serhiy Storchaka2014-01-201-14/+0
| | | | | | | | versions.
| * remove trailing spaces.Gregory P. Smith2013-12-181-7/+7
| |
* | whatsnew for gc.get_stats, plus doc tweaks.R David Murray2013-12-261-0/+1
| | | | | | | | | | | | | | | | | | | | Clarified the "At the moment" wording, and added the get_stats entry in the module summary that Serhiy noted was missing at the end of issue 16351. Given that pydoc lists all the function docstrings, I'm not sure that module summary section is actually needed; but, it is probably better to address that when the module is converted to use Argument Clinic. In the meantime we should keep the list complete.
* | Replace an overly optimistic assert() in _PyGC_CollectNoFail with a simple ↵Antoine Pitrou2013-08-151-6/+13
| | | | | | | | guard.
* | In _PyGC_Fini(), lose the reference that was kept to the time moduleAntoine Pitrou2013-08-061-0/+1
| |
* | Issue #18112: PEP 442 implementation (safe object finalization).Antoine Pitrou2013-07-301-49/+107
| |
* | Issue #18408: PyObject_GC_NewVar() now raises SystemError exception if nitemsVictor Stinner2013-07-081-2/+9
| | | | | | | | is negative
* | gcmodule.c: strip trailing spacesVictor Stinner2013-07-081-7/+7
| |
* | Issue #17937: Try harder to collect cyclic garbage at shutdown.Antoine Pitrou2013-05-181-6/+25
| |
* | Backout c89febab4648 following private feedback by Guido.Antoine Pitrou2013-05-141-1/+4
| | | | | | | | (Issue #17807: Generators can now be finalized even when they are part of a reference cycle)
* | Issue #17807: Generators can now be finalized even when they are part of a ↵Antoine Pitrou2013-05-081-4/+1
| | | | | | | | reference cycle.