getdns-python-bindings
getdns-python-bindings copied to clipboard
Doing queries leak memory
Some structures allocated by the binding are not being freed/dereffed correctly. A simple testcase:
import resource import getdns
resolver = getdns.Context()
for i in range(10000): extensions = {"return_both_v4_and_v6": getdns.EXTENSION_TRUE} res = resolver.address(name="google.com", extensions=extensions) if i % 100 == 0: print(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)
$ pip3 list|grep getdns getdns (1.0b0)
By way of an update, I've isolated this to the result object and am continuing to look into it.
I am facing the same issue. I am performing DNS lookup inside a flask app. So with each request, the memory usage keeps on increasing. The memory gets freed only after the app is restarted/stopped.
A sample code:
import getdns
from flask import Flask, jsonify
app = Flask(__name__)
@app.route('/address')
def get_address():
name = 'google.com'
extensions = {"return_both_v4_and_v6": getdns.EXTENSION_TRUE}
ctx = getdns.Context()
response = ctx.address(name, extensions=extensions)
return jsonify(data=response.just_address_answers)
if __name__ == '__main__':
app.run()
Am I missing something? Is there any way to destroy the result object on request completion?