summaryrefslogtreecommitdiffstats
path: root/Modules/_tracemalloc.c
Commit message (Collapse)AuthorAgeFilesLines
* bpo-29564:_PyMem_DumpTraceback() suggests enabling tracemalloc (GH-10510)Victor Stinner2018-11-131-0/+6
| | | | | If tracemalloc is not tracing Python memory allocations, _PyMem_DumpTraceback() now suggests to enable tracemalloc to get the traceback where the memory block has been allocated.
* bpo-9263: Dump Python object on GC assertion failure (GH-10062)Victor Stinner2018-10-251-2/+4
| | | | | | | | | | | | | | | | | | | | | | | 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>
* bpo-35053: Enhance tracemalloc to trace free lists (GH-10063)Victor Stinner2018-10-251-51/+84
| | | | | | | | | | | | tracemalloc now tries to update the traceback when an object is reused from a "free list" (optimization for faster object creation, used by the builtin list type for example). Changes: * Add _PyTraceMalloc_NewReference() function which tries to update the Python traceback of a Python object. * _Py_NewReference() now calls _PyTraceMalloc_NewReference(). * Add an unit test.
* bpo-32030: Enhance Py_Main() (#4412)Victor Stinner2017-11-161-92/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Parse more env vars in Py_Main(): * Add more options to _PyCoreConfig: * faulthandler * tracemalloc * importtime * Move code to parse environment variables from _Py_InitializeCore() to Py_Main(). This change fixes a regression from Python 3.6: PYTHONUNBUFFERED is now read before calling pymain_init_stdio(). * _PyFaulthandler_Init() and _PyTraceMalloc_Init() now take an argument to decide if the module has to be enabled at startup. * tracemalloc_start() is now responsible to check the maximum number of frames. Other changes: * Cleanup Py_Main(): * Rename some pymain_xxx() subfunctions * Add pymain_run_python() subfunction * Cleanup Py_NewInterpreter() * _PyInterpreterState_Enable() now reports failure * init_hash_secret() now considers pyurandom() failure as an "user error": don't fail with abort(). * pymain_optlist_append() and pymain_strdup() now sets err on memory allocation failure.
* bpo-25658: Implement PEP 539 for Thread Specific Storage (TSS) API (GH-1362)Masayuki Yamamoto2017-10-061-17/+8
| | | | | | | | | See PEP 539 for details. Highlights of changes: - Add Thread Specific Storage (TSS) API - Document the Thread Local Storage (TLS) API as deprecated - Update code that used TLS API to use TSS API
* bpo-31338 (#3374)Barry Warsaw2017-09-151-1/+1
| | | | | | | * Add Py_UNREACHABLE() as an alias to abort(). * Use Py_UNREACHABLE() instead of assert(0) * Convert more unreachable code to use Py_UNREACHABLE() * Document Py_UNREACHABLE() and a few other macros.
* bpo-31370: Remove support for threads-less builds (#3385)Antoine Pitrou2017-09-071-36/+5
| | | | | | * Remove Setup.config * Always define WITH_THREAD for compatibility.
* bpo-31018: Switch to #pragma pack from __declspec(align) (#2848)Segev Finer2017-07-251-1/+4
|
* bpo-30961: Fix decrementing a borrowed reference in tracemalloc. (#2747)Xiang Zhang2017-07-181-2/+1
|
* bpo-30054: Expose tracemalloc C API (#1236)Victor Stinner2017-06-201-10/+10
| | | | | | | | | * Make PyTraceMalloc_Track() and PyTraceMalloc_Untrack() functions public (remove the "_" prefix) * Remove the _PyTraceMalloc_domain_t type: use directly unsigned int. * Document methods Note: methods are already tested in test_tracemalloc.
* Issue #20186: Regenerated Argument Clinic.Serhiy Storchaka2017-02-051-1/+1
|
* Issue #20186: Converted the tracemalloc module to Argument Clinic.Serhiy Storchaka2017-02-041-102/+123
| | | | Based on patch by Georg Brandl.
* replace PY_SIZE_MAX with SIZE_MAXBenjamin Peterson2016-09-071-2/+2
|
* replace Py_(u)intptr_t with the c99 standard typesBenjamin Peterson2016-09-061-15/+15
|
* Issue #27895: Spelling fixes (Contributed by Ville Skyttä).Raymond Hettinger2016-08-301-1/+1
|
* - make some internal symbols staticdoko@ubuntu.com2016-05-171-1/+1
|
* Issue #26778: Fixed "a/an/and" typos in code comment, documentation and errorSerhiy Storchaka2016-04-171-1/+1
|\ | | | | | | messages.
| * Issue #26778: Fixed "a/an/and" typos in code comment and documentation.Serhiy Storchaka2016-04-171-1/+1
| |
* | Issue #15984: Merge PyUnicode doc from 3.5Martin Panter2016-04-151-1/+1
|\ \ | |/
| * Correct “an” → “a” with “Unicode”, “user”, “UTF”, etcMartin Panter2016-04-151-1/+1
| | | | | | | | This affects documentation, code comments, and a debugging messages.
* | _tracemalloc: use compact key for tracesVictor Stinner2016-03-231-1/+61
| | | | | | | | | | | | Issue #26588: Optimize memory footprint of _tracemalloc before non-zero domain is used. Start with compact key (Py_uintptr_t) and also switch to pointer_t key when the first memory block with a non-zero domain is tracked.
* | Cleanup hashtable.hVictor Stinner2016-03-231-26/+24
| | | | | | | | | | | | | | | | | | | | | | | | Issue #26588: * Pass the hash table rather than the key size to hash and compare functions * _Py_HASHTABLE_READ_KEY() and _Py_HASHTABLE_ENTRY_READ_KEY() macros now expect the hash table as the first parameter, rather than the key size * tracemalloc_get_traces_fill(): use _Py_HASHTABLE_ENTRY_READ_DATA() rather than pointer dereference * Remove the _Py_HASHTABLE_ENTRY_WRITE_PKEY() macro * Move "PKEY" and "PDATA" macros inside hashtable.c
* | Issue #26588:Victor Stinner2016-03-231-11/+27
| | | | | | | | | | | | | | * Optimize tracemalloc_add_trace(): modify hashtable entry data (trace) if the memory block is already tracked, rather than trying to remove the old trace and then add a new trace. * Add _Py_HASHTABLE_ENTRY_WRITE_DATA() macro
* | Issue #26588:Victor Stinner2016-03-231-1/+1
| | | | | | | | | | | | | | | | * _Py_HASHTABLE_ENTRY_DATA: change type from "char *" to "const void *" * Add _Py_HASHTABLE_ENTRY_WRITE_PKEY() macro * Rename _Py_HASHTABLE_ENTRY_WRITE_DATA() macro to _Py_HASHTABLE_ENTRY_WRITE_PDATA() * Add _Py_HASHTABLE_ENTRY_WRITE_DATA() macro
* | Issue #26588: Optimize tracemalloc_realloc()Victor Stinner2016-03-231-1/+6
| | | | | | | | No need to remove the old trace if the memory block didn't move.
* | Merge 3.5Victor Stinner2016-03-221-15/+1
|\ \ | |/
| * Enhance _tracemalloc debug modeVictor Stinner2016-03-221-1/+1
| | | | | | | | Issue #26588: Enhance assertion in set_reentrant()
| * Fix _tracemalloc start/stopVictor Stinner2016-03-221-14/+0
| | | | | | | | | | | | | | | | | | Issue #26588: Fix _tracemalloc start/stop: don't play with the reentrant flag. set_reentrant(1) fails with an assertion error if tracemalloc_init() is called first in a thread A and tracemalloc_start() is called second in a thread B. The tracemalloc is imported in a thread A. Importing the module calls tracemalloc_init(). tracemalloc.start() is called in a thread B.
* | Issue #26588: remove debug traces from _tracemalloc.Victor Stinner2016-03-221-64/+5
| |
* | Issue #26588: more debug tracesVictor Stinner2016-03-221-1/+6
| |
* | Issue #26588: Don't call tracemalloc_init() at module initilizationVictor Stinner2016-03-221-0/+2
| | | | | | | | So it's possible to get debug messages in test_tracemalloc.
* | Issue #26588: one more assertionVictor Stinner2016-03-221-0/+1
| |
* | Add assertions on tracemalloc_reentrant_keyVictor Stinner2016-03-221-2/+8
| | | | | | | | Issue #26588.
* | Issue #26588: more assertionsVictor Stinner2016-03-221-2/+23
| |
* | Issue #26588: add debug tracesVictor Stinner2016-03-221-5/+35
| | | | | | | | Try to debug random failure on buildbots.
* | Add C functions _PyTraceMalloc_Track()Victor Stinner2016-03-221-11/+71
| | | | | | | | | | | | | | | | Issue #26530: * Add C functions _PyTraceMalloc_Track() and _PyTraceMalloc_Untrack() to track memory blocks using the tracemalloc module. * Add _PyTraceMalloc_GetTraceback() to get the traceback of an object.
* | tracemalloc now supports domainsVictor Stinner2016-03-221-53/+214
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue #26588: * The _tracemalloc now supports tracing memory allocations of multiple address spaces (domains). * Add domain parameter to tracemalloc_add_trace() and tracemalloc_remove_trace(). * tracemalloc_add_trace() now starts by removing the previous trace, if any. * _tracemalloc._get_traces() now returns a list of (domain, size, traceback_frames): the domain is new. * Add tracemalloc.DomainFilter * tracemalloc.Filter: add an optional domain parameter to the constructor and a domain attribute * Sublte change: use Py_uintptr_t rather than void* in the traces key. * Add tracemalloc_config.use_domain, currently hardcoded to 1
* | Simplify implementation of hashtable.cVictor Stinner2016-03-221-6/+8
| | | | | | | | | | | | | | | | | | | | | | Issue #26588: Remove copy_data, free_data and get_data_size callbacks from hashtable.h. These callbacks are not used in Python and makes the code more complex. Remove also the _Py_HASHTABLE_ENTRY_DATA_AS_VOID_P() macro which uses an unsafe pointer dereference (can cause memory alignment issue). Replace the macro usage with _Py_HASHTABLE_ENTRY_READ_DATA() which is implemented with the safe memcpy() function.
* | Issue #26588: Fix compilation warning on WindowsVictor Stinner2016-03-211-1/+1
| |
* | hashtable.h now supports keys of any sizeVictor Stinner2016-03-211-37/+68
| | | | | | | | | | | | Issue #26588: hashtable.h now supports keys of any size, not only sizeof(void*). It allows to support key larger than sizeof(void*), but also to use less memory for key smaller than sizeof(void*).
* | Ooops, revert changeset ea9efa06c137Victor Stinner2016-03-211-138/+48
| | | | | | | | | | | | | | | | | | | | | | Change pushed by mistake, the patch is still under review :-/ """ _tracemalloc: add domain to trace keys * hashtable.h: key has now a variable size * _tracemalloc uses (pointer: void*, domain: unsigned int) as key for traces """
* | _tracemalloc: add domain to trace keysVictor Stinner2016-03-181-48/+138
| | | | | | | | | | * hashtable.h: key has now a variable size * _tracemalloc uses (pointer: void*, domain: unsigned int) as key for traces
* | On memory error, dump the memory block tracebackVictor Stinner2016-03-151-11/+56
| | | | | | | | | | | | Issue #26564: _PyObject_DebugDumpAddress() now dumps the traceback where a memory block was allocated on memory block. Use the tracemalloc module to get the traceback.
* | Merge 3.5 (_tracemalloc)Victor Stinner2016-03-151-17/+7
|\ \ | |/
| * _tracemalloc: store lineno as unsigned intVictor Stinner2016-03-151-17/+7
| | | | | | | | Issue #26564. Cleanup the code, lineno is never negative.
* | _tracemalloc: filename cannot be NULLVictor Stinner2016-03-151-2/+2
| |
* | Issue #26558: Remove useless check in tracemallocVictor Stinner2016-03-141-4/+0
|/ | | | | The first instruction of tracemalloc_add_trace() is traceback_new() which already checks the GIL.
* Merge 3.4 (tracemalloc typo)Victor Stinner2015-03-181-1/+1
|\
| * _tracemalloc.c: Fix typoVictor Stinner2015-03-181-1/+1
| |
* | Removed duplicated words in in comments and docs.Serhiy Storchaka2014-12-011-1/+1
|\ \ | |/