Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Doc/c-api/init_config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -546,13 +546,6 @@ PyConfig
Only available on Windows. ``#ifdef MS_WINDOWS`` macro can be used for
Windows specific code.

.. c:member:: int malloc_stats

If non-zero, dump statistics on :ref:`Python pymalloc memory allocator
<pymalloc>` at exit.

The option is ignored if Python is built using ``--without-pymalloc``.

.. c:member:: wchar_t* pythonpath_env

Module search paths as a string separated by ``DELIM``
Expand Down
4 changes: 0 additions & 4 deletions Doc/c-api/memory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ for the I/O buffer escapes completely the Python memory manager.
The :envvar:`PYTHONMALLOC` environment variable can be used to configure
the memory allocators used by Python.

The :envvar:`PYTHONMALLOCSTATS` environment variable can be used to print
statistics of the :ref:`pymalloc memory allocator <pymalloc>` every time a
new pymalloc object arena is created, and on shutdown.


Raw Memory Interface
====================
Expand Down
16 changes: 0 additions & 16 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -214,22 +214,6 @@ always available.

.. versionadded:: 3.7

.. function:: _debugmallocstats()

Print low-level information to stderr about the state of CPython's memory
allocator.

If Python is configured --with-pydebug, it also performs some expensive
internal consistency checks.

.. versionadded:: 3.3

.. impl-detail::

This function is specific to CPython. The exact output format is not
defined here, and may change.


.. data:: dllhandle

Integer specifying the handle of the Python DLL.
Expand Down
15 changes: 0 additions & 15 deletions Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -791,21 +791,6 @@ conflict.
.. versionadded:: 3.6


.. envvar:: PYTHONMALLOCSTATS

If set to a non-empty string, Python will print statistics of the
:ref:`pymalloc memory allocator <pymalloc>` every time a new pymalloc object
arena is created, and on shutdown.

This variable is ignored if the :envvar:`PYTHONMALLOC` environment variable
is used to force the :c:func:`malloc` allocator of the C library, or if
Python is configured without ``pymalloc`` support.

.. versionchanged:: 3.6
This variable can now also be used on Python compiled in release mode.
It now has no effect if set to an empty string.


.. envvar:: PYTHONLEGACYWINDOWSFSENCODING

If set to a non-empty string, the default filesystem encoding and errors mode
Expand Down
4 changes: 4 additions & 0 deletions Doc/whatsnew/3.10.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ Deprecated
Removed
=======

* The ``sys._debugmallocstats()`` function and the ``PYTHONMALLOCSTATS``
environment variable have been removed.
(Contributed by Victor Stinner in :issue:`40781`.)


Porting to Python 3.10
======================
Expand Down
1 change: 0 additions & 1 deletion Include/cpython/dictobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ PyAPI_FUNC(PyObject *) _PyDict_GetItemId(PyObject *dp, struct _Py_Identifier *ke
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);

PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);

int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
Expand Down
2 changes: 0 additions & 2 deletions Include/cpython/frameobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int);
PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f);
PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);

PyAPI_FUNC(void) _PyFrame_DebugMallocStats(FILE *out);

PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame);

#ifdef __cplusplus
Expand Down
1 change: 0 additions & 1 deletion Include/cpython/initconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ typedef struct {
int import_time; /* PYTHONPROFILEIMPORTTIME, -X importtime */
int show_ref_count; /* -X showrefcount */
int dump_refs; /* PYTHONDUMPREFS */
int malloc_stats; /* PYTHONMALLOCSTATS */

/* Python filesystem encoding and error handler:
sys.getfilesystemencoding() and sys.getfilesystemencodeerrors().
Expand Down
1 change: 0 additions & 1 deletion Include/cpython/listobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ typedef struct {
} PyListObject;

PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);

/* Macro, trading safety for speed */

Expand Down
6 changes: 0 additions & 6 deletions Include/cpython/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,12 +386,6 @@ PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;
*/
PyAPI_DATA(int) _Py_SwappedOp[];

PyAPI_FUNC(void)
_PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks,
size_t sizeof_block);
PyAPI_FUNC(void)
_PyObject_DebugTypeStats(FILE *out);

/* Define a pair of assertion macros:
_PyObject_ASSERT_FROM(), _PyObject_ASSERT_WITH_MSG() and _PyObject_ASSERT().

Expand Down
6 changes: 0 additions & 6 deletions Include/cpython/objimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,6 @@ _PyObject_INIT_VAR(PyVarObject *op, PyTypeObject *typeobj, Py_ssize_t size)
/* This function returns the number of allocated memory blocks, regardless of size */
PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);

/* Macros */
#ifdef WITH_PYMALLOC
PyAPI_FUNC(int) _PyObject_DebugMallocStats(FILE *out);
#endif


typedef struct {
/* user context passed as the first argument to the 2 functions */
void *ctx;
Expand Down
2 changes: 0 additions & 2 deletions Include/cpython/tupleobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
/* Macro, *only* to be used to fill in brand new tuples */
#define PyTuple_SET_ITEM(op, i, v) (_PyTuple_CAST(op)->ob_item[i] = v)

PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);

#ifdef __cplusplus
}
#endif
2 changes: 0 additions & 2 deletions Include/floatobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ PyAPI_FUNC(double) _PyFloat_Unpack2(const unsigned char *p, int le);
PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le);
PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le);

PyAPI_FUNC(void) _PyFloat_DebugMallocStats(FILE* out);

/* Format the object based on the format_spec, as defined in PEP 3101
(Advanced String Formatting). */
PyAPI_FUNC(int) _PyFloat_FormatAdvancedWriter(
Expand Down
4 changes: 0 additions & 4 deletions Lib/test/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ class InitConfigTests(EmbeddingTestsMixin, unittest.TestCase):
'import_time': 0,
'show_ref_count': 0,
'dump_refs': 0,
'malloc_stats': 0,

'filesystem_encoding': GET_DEFAULT_CONFIG,
'filesystem_errors': GET_DEFAULT_CONFIG,
Expand Down Expand Up @@ -729,7 +728,6 @@ def test_init_from_config(self):
'tracemalloc': 2,
'import_time': 1,
'show_ref_count': 1,
'malloc_stats': 1,
'_use_peg_parser': 0,

'stdio_encoding': 'iso8859-1',
Expand Down Expand Up @@ -782,7 +780,6 @@ def test_init_compat_env(self):
'hash_seed': 42,
'tracemalloc': 2,
'import_time': 1,
'malloc_stats': 1,
'inspect': 1,
'optimization_level': 2,
'pythonpath_env': '/my/path',
Expand Down Expand Up @@ -810,7 +807,6 @@ def test_init_python_env(self):
'hash_seed': 42,
'tracemalloc': 2,
'import_time': 1,
'malloc_stats': 1,
'inspect': 1,
'optimization_level': 2,
'pythonpath_env': '/my/path',
Expand Down
11 changes: 0 additions & 11 deletions Lib/test/test_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -770,17 +770,6 @@ def test_implementation(self):
self.assertEqual(sys.implementation.name,
sys.implementation.name.lower())

@test.support.cpython_only
def test_debugmallocstats(self):
# Test sys._debugmallocstats()
from test.support.script_helper import assert_python_ok
args = ['-c', 'import sys; sys._debugmallocstats()']
ret, out, err = assert_python_ok(*args)
self.assertIn(b"free PyDictObjects", err)

# The function has no parameter
self.assertRaises(TypeError, sys._debugmallocstats, True)

@unittest.skipUnless(hasattr(sys, "getallocatedblocks"),
"sys.getallocatedblocks unavailable on this build")
def test_getallocatedblocks(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The ``sys._debugmallocstats()`` function and the ``PYTHONMALLOCSTATS``
environment variable have been removed.
6 changes: 0 additions & 6 deletions Misc/SpecialBuilds.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ getting used).
Note that PYMALLOC_DEBUG requires WITH_PYMALLOC. Py_DEBUG implies
PYMALLOC_DEBUG (if WITH_PYMALLOC is enabled).

Special gimmicks:

envvar PYTHONMALLOCSTATS
If this envvar exists, a report of pymalloc summary statistics is printed to
stderr whenever a new arena is allocated, and also by Py_FinalizeEx().

Changed in 2.5: The number of extra bytes allocated is 4*sizeof(size_t).
Before it was 16 on all boxes, reflecting that Python couldn't make use of
allocations >= 2**32 bytes even on 64-bit boxes before 2.5.
Expand Down
10 changes: 0 additions & 10 deletions Misc/python.man
Original file line number Diff line number Diff line change
Expand Up @@ -491,16 +491,6 @@ When Python is compiled in debug mode, the default is
.IR pymalloc_debug
and the debug hooks are automatically used. Otherwise, the default is
.IR pymalloc .
.IP PYTHONMALLOCSTATS
If set to a non-empty string, Python will print statistics of the pymalloc
memory allocator every time a new pymalloc object arena is created, and on
shutdown.
.IP
This variable is ignored if the
.RB $ PYTHONMALLOC
environment variable is used to force the
.BR malloc (3)
allocator of the C library, or if Python is configured without pymalloc support.
.IP PYTHONASYNCIODEBUG
If this environment variable is set to a non-empty string, enable the debug
mode of the asyncio module.
Expand Down
11 changes: 0 additions & 11 deletions Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,17 +281,6 @@ _PyDict_ClearFreeList(void)
#endif
}

/* Print summary info about the state of the optimized allocator */
void
_PyDict_DebugMallocStats(FILE *out)
{
#if PyDict_MAXFREELIST > 0
_PyDebugAllocatorStats(out,
"free PyDictObject", numfree, sizeof(PyDictObject));
#endif
}


void
_PyDict_Fini(void)
{
Expand Down
9 changes: 0 additions & 9 deletions Objects/floatobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1998,15 +1998,6 @@ _PyFloat_Fini(void)
_PyFloat_ClearFreeList();
}

/* Print summary info about the state of the optimized allocator */
void
_PyFloat_DebugMallocStats(FILE *out)
{
_PyDebugAllocatorStats(out,
"free PyFloatObject",
numfree, sizeof(PyFloatObject));
}


/*----------------------------------------------------------------------------
* _PyFloat_{Pack,Unpack}{2,4,8}. See floatobject.h.
Expand Down
12 changes: 0 additions & 12 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,18 +1200,6 @@ _PyFrame_Fini(void)
_PyFrame_ClearFreeList();
}

/* Print summary info about the state of the optimized allocator */
void
_PyFrame_DebugMallocStats(FILE *out)
{
#if PyFrame_MAXFREELIST > 0
_PyDebugAllocatorStats(out,
"free PyFrameObject",
numfree, sizeof(PyFrameObject));
#endif
}


PyCodeObject *
PyFrame_GetCode(PyFrameObject *frame)
{
Expand Down
8 changes: 0 additions & 8 deletions Objects/listobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,6 @@ _PyList_Fini(void)
_PyList_ClearFreeList();
}

/* Print summary info about the state of the optimized allocator */
void
_PyList_DebugMallocStats(FILE *out)
{
_PyDebugAllocatorStats(out,
"free PyListObject",
numfree, sizeof(PyListObject));
}

PyObject *
PyList_New(Py_ssize_t size)
Expand Down
11 changes: 0 additions & 11 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1931,17 +1931,6 @@ _Py_GetObjects(PyObject *self, PyObject *args)
/* Hack to force loading of abstract.o */
Py_ssize_t (*_Py_abstract_hack)(PyObject *) = PyObject_Size;


void
_PyObject_DebugTypeStats(FILE *out)
{
_PyDict_DebugMallocStats(out);
_PyFloat_DebugMallocStats(out);
_PyFrame_DebugMallocStats(out);
_PyList_DebugMallocStats(out);
_PyTuple_DebugMallocStats(out);
}

/* These methods are used to control infinite recursion in repr, str, print,
etc. Container objects that may recursively contain themselves,
e.g. builtin dictionaries and lists, should use Py_ReprEnter() and
Expand Down
Loading