Maintained by: NLnet Labs

[Unbound-users] Memory leak when accessing qstate members from a python module?

W.C.A. Wijngaards
Tue May 10 11:47:39 CEST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Alexander,

On 04/11/2011 08:10 PM, Alexander Case wrote:
> Hello,
> 
>     When writing a python module for unbound my module appeared to be
> leaking memory. It uses unbound 1.4.9 and swig 1.3.40. I've isolated the
> problem to one line that accesses
> "qstate.return_msg.rep.rrsets[i].rk.type_str".
> 
> As a test I modified the dict.py example file to contain the offending
> line and also
> added the range 2000 loop to exacerbate the problem, causing a few
> megabytes of
> ram to be consumed every second or so.
> 
> Below is the small addition I made to dict.py to illustrate the issue,
> 
>    elif event == MODULE_EVENT_MODDONE: #the iterator has finished
>         if qstate.return_msg and qstate.return_msg.rep:
>             for i in range(0, 2000):
>                 for i in range(0,qstate.return_msg.rep.rrset_count):
>                     s = qstate.return_msg.rep.rrsets[i].rk.type_str
>          #we don't need modify result
>         qstate.ext_state[id] = MODULE_FINISHED
>         return True
> 
> 
> I tried setting s to a static string as well as qstate.return_msg.rep and
> memory usage remained constant with no leak. This is on a server that is
> getting 20-30qps.
> 
> Could this be a problem in unbound or swig? Is there something I should do
> differently?

Probably in the pythonmod/interface.i definitions.  The ldns type2str
call there.  You could attempt to contact the original authors of the
python module, pythonmod/LICENSE names them, Zdenek Vasicek and Marek
Vavrusa (and has their email addresses).

Best regards,
   Wouter
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJNyQm7AAoJEJ9vHC1+BF+NlXMP/jbswXbP3sT44ds8gR7pYhrg
5TLuaZFIGO/3DbtS5qabWmplcf0HE0ZuO8bkyR90uaN0HJ6drqTHxREiK1VRX/m0
stK48L85tZc8ng+yzQp/oEkKZ6FTXPEpw9ZEfTYKebs5OB3cFI5leL91D9q+YIUZ
6RDvFqhoHXftBIb6mOaffz24QNyZ9S+H+c2pbYXRhFUrG1rYy5JR8cV7nDWtz0wf
UhrmL/x5+asjOUwqJcP1yY4MWSyfZ5oluT87nSj3Pb9L3SepMQO4rBrqX2K4WgKt
Wo4MKIRRVi1HEJAQhjMDDN10Hvn+qLJTS7hCckj6NpumFYcIHXb1//BbL1fi4KKd
ZlsAUD0VOHiQsHV7V1zWJGvTMRO/aS4n9ucOf5wCf5L46JPJgDRAk4z+umM4s6jR
D7l7FPnuLvwxC9mZ3wn+Lzl8lv5+M/f53S+YogyoM++71pBM04/4oshq3svk+krT
ZR+nQUlmzI7P/YR0JdTBiagJTF8zLT3EBgIXXBcBCeELlznVCL8cE+yX9FS+lVoK
abLV/0wCVBpnq7SpSvBcknxID+2A4qQJToucu1CKkc3aSz4+xTnTiifz17y/OXhL
VYiDaVge8Ss/lBdHC+B/PHxu+yaUAG/bhFr3ses29+k9Ph/iyQOzRyQ8imLO0NUn
+j31nxw/RoVp+8kD+Z3V
=MuTQ
-----END PGP SIGNATURE-----