comparison Python/sysmodule.c @ 80777:c40f4c19d20b

Issue #13390: New function :func:`sys.getallocatedblocks()` returns the number of memory blocks currently allocated. Also, the ``-R`` option to regrtest uses this function to guard against memory allocation leaks.
author Antoine Pitrou <solipsis@pitrou.net>
date Sun, 09 Dec 2012 14:28:26 +0100
parents ceb0184c7f44
children 1da78c7d382b
comparison
equal deleted inserted replaced
80776:04eb89e078b5 80777:c40f4c19d20b
890 "getrefcount(object) -> integer\n\ 890 "getrefcount(object) -> integer\n\
891 \n\ 891 \n\
892 Return the reference count of object. The count returned is generally\n\ 892 Return the reference count of object. The count returned is generally\n\
893 one higher than you might expect, because it includes the (temporary)\n\ 893 one higher than you might expect, because it includes the (temporary)\n\
894 reference as an argument to getrefcount()." 894 reference as an argument to getrefcount()."
895 );
896
897 static PyObject *
898 sys_getallocatedblocks(PyObject *self)
899 {
900 return PyLong_FromSsize_t(_Py_GetAllocatedBlocks());
901 }
902
903 PyDoc_STRVAR(getallocatedblocks_doc,
904 "getallocatedblocks() -> integer\n\
905 \n\
906 Return the number of memory blocks currently allocated, regardless of their\n\
907 size."
895 ); 908 );
896 909
897 #ifdef COUNT_ALLOCS 910 #ifdef COUNT_ALLOCS
898 static PyObject * 911 static PyObject *
899 sys_getcounts(PyObject *self) 912 sys_getcounts(PyObject *self)
1060 METH_NOARGS, getdefaultencoding_doc}, 1073 METH_NOARGS, getdefaultencoding_doc},
1061 #ifdef HAVE_DLOPEN 1074 #ifdef HAVE_DLOPEN
1062 {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, 1075 {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS,
1063 getdlopenflags_doc}, 1076 getdlopenflags_doc},
1064 #endif 1077 #endif
1078 {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS,
1079 getallocatedblocks_doc},
1065 #ifdef COUNT_ALLOCS 1080 #ifdef COUNT_ALLOCS
1066 {"getcounts", (PyCFunction)sys_getcounts, METH_NOARGS}, 1081 {"getcounts", (PyCFunction)sys_getcounts, METH_NOARGS},
1067 #endif 1082 #endif
1068 #ifdef DYNAMIC_EXECUTION_PROFILE 1083 #ifdef DYNAMIC_EXECUTION_PROFILE
1069 {"getdxp", _Py_GetDXProfile, METH_VARARGS}, 1084 {"getdxp", _Py_GetDXProfile, METH_VARARGS},