Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doing queries leak memory #43

Open
rytilahti opened this issue Aug 1, 2016 · 2 comments
Open

Doing queries leak memory #43

rytilahti opened this issue Aug 1, 2016 · 2 comments

Comments

@rytilahti
Copy link

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)

@MelindaShore
Copy link
Contributor

By way of an update, I've isolated this to the result object and am continuing to look into it.

@Autopilot9369
Copy link

Autopilot9369 commented Sep 23, 2019

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants