[Python-checkins] cpython: Issue #26588: Optimize tracemalloc_realloc()
victor.stinner
python-checkins at python.org
Wed Mar 23 04:08:33 EDT 2016
https://hg.python.org/cpython/rev/dd887518b569
changeset: 100674:dd887518b569
user: Victor Stinner <victor.stinner at gmail.com>
date: Wed Mar 23 09:08:08 2016 +0100
summary:
Issue #26588: Optimize tracemalloc_realloc()
No need to remove the old trace if the memory block didn't move.
files:
Modules/_tracemalloc.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -633,7 +633,12 @@
/* an existing memory block has been resized */
TABLES_LOCK();
- REMOVE_TRACE(ptr);
+
+ /* tracemalloc_add_trace() updates the trace if there is already
+ a trace at address (domain, ptr2) */
+ if (ptr2 != ptr) {
+ REMOVE_TRACE(ptr);
+ }
if (ADD_TRACE(ptr2, new_size) < 0) {
/* Memory allocation failed. The error cannot be reported to
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list