Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(42825)

Side by Side Diff: Python/sysmodule.c

Issue 13390: Hunt memory allocations in addition to reference leaks
Patch Set: Created 6 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Python/pythonrun.c ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* System module */ 2 /* System module */
3 3
4 /* 4 /*
5 Various bits of information used by the interpreter are collected in 5 Various bits of information used by the interpreter are collected in
6 module 'sys'. 6 module 'sys'.
7 Function member: 7 Function member:
8 - exit(sts): raise SystemExit 8 - exit(sts): raise SystemExit
9 Data members: 9 Data members:
10 - stdin, stdout, stderr: standard file objects 10 - stdin, stdout, stderr: standard file objects
(...skipping 874 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 return PyLong_FromSsize_t(_Py_GetRefTotal()); 885 return PyLong_FromSsize_t(_Py_GetRefTotal());
886 } 886 }
887 #endif /* Py_REF_DEBUG */ 887 #endif /* Py_REF_DEBUG */
888 888
889 PyDoc_STRVAR(getrefcount_doc, 889 PyDoc_STRVAR(getrefcount_doc,
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_GetAllocedBlocks());
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)
900 { 913 {
901 extern PyObject *get_counts(void); 914 extern PyObject *get_counts(void);
902 915
903 return get_counts(); 916 return get_counts();
904 } 917 }
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 {"displayhook", sys_displayhook, METH_O, displayhook_doc}, 1068 {"displayhook", sys_displayhook, METH_O, displayhook_doc},
1056 {"exc_info", sys_exc_info, METH_NOARGS, exc_info_doc}, 1069 {"exc_info", sys_exc_info, METH_NOARGS, exc_info_doc},
1057 {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc}, 1070 {"excepthook", sys_excepthook, METH_VARARGS, excepthook_doc},
1058 {"exit", sys_exit, METH_VARARGS, exit_doc}, 1071 {"exit", sys_exit, METH_VARARGS, exit_doc},
1059 {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding, 1072 {"getdefaultencoding", (PyCFunction)sys_getdefaultencoding,
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},
1070 #endif 1085 #endif
1071 {"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding, 1086 {"getfilesystemencoding", (PyCFunction)sys_getfilesystemencoding,
1072 METH_NOARGS, getfilesystemencoding_doc}, 1087 METH_NOARGS, getfilesystemencoding_doc},
1073 #ifdef Py_TRACE_REFS 1088 #ifdef Py_TRACE_REFS
1074 {"getobjects", _Py_GetObjects, METH_VARARGS}, 1089 {"getobjects", _Py_GetObjects, METH_VARARGS},
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after
2079 2094
2080 void 2095 void
2081 PySys_FormatStderr(const char *format, ...) 2096 PySys_FormatStderr(const char *format, ...)
2082 { 2097 {
2083 va_list va; 2098 va_list va;
2084 2099
2085 va_start(va, format); 2100 va_start(va, format);
2086 sys_format("stderr", stderr, format, va); 2101 sys_format("stderr", stderr, format, va);
2087 va_end(va); 2102 va_end(va);
2088 } 2103 }
OLDNEW
« no previous file with comments | « Python/pythonrun.c ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+