Python memory leaks?

后端 未结 2 409
天命终不由人
天命终不由人 2021-01-12 11:21

I am writing a python extension that seems to be leaking memory. I am trying to figure out the soure of the problem using valgrind.

However, it seems that python it

2条回答
  •  走了就别回头了
    2021-01-12 12:24

    There's a whole README.valgrind in the Python sources that explains the various caveats trying to use Valgrind with Python:

    http://svn.python.org/projects/python/trunk/Misc/README.valgrind

    Python uses its own small-object allocation scheme on top of malloc,
    called PyMalloc.
    
    Valgrind may show some unexpected results when PyMalloc is used.
    Starting with Python 2.3, PyMalloc is used by default.  You can disable
    PyMalloc when configuring python by adding the --without-pymalloc option.
    If you disable PyMalloc, most of the information in this document and
    the supplied suppressions file will not be useful.  As discussed above,
    disabling PyMalloc can catch more problems.
    
    If you use valgrind on a default build of Python,  you will see
    many errors like:
    
            ==6399== Use of uninitialised value of size 4
            ==6399== at 0x4A9BDE7E: PyObject_Free (obmalloc.c:711)
            ==6399== by 0x4A9B8198: dictresize (dictobject.c:477)
    
    These are expected and not a problem. 
    

提交回复
热议问题