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

Alexander Case case.ax at gmail.com
Mon Apr 11 18:10:38 UTC 2011


	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


More information about the Unbound-users mailing list