Le Fri, 26 Jul 2013 16:29:59 +0200, Christian Heimes <christian at python.org> a écrit : > Coverity is able to detect some cases of refcount leaks. I don't know > if the software is able to keep track of all reference counts. But it > understands missing Py_DECREF() in error branches. > > For example: > > PyObject *n = PyLong_FromLong(0); > PyObject *u = PyUnicode_FromString("example"); > > if (u == NULL) { > return NULL; > /* Coverity detects that 'n' leaks memory */ > } But 'n' doesn't leak memory since PyLong_FromLong(0) is statically allocated ;-) More generally, in similar cases (e.g. replace "0" with a non-small integer), you don't need any knowledge of reference counts to infer that there is a memory leak. When the code discards the only existing pointer to a heap-allocated memory area, there's a leak. What we call "refcount leaks" is generally when an area is still pointer-accessible, but failure to decrement the reference count appropriately means it will never be released. Regards Antoine.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4