We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
Connection object without calling close() explicitly will cause memory leak.
Connection
close()
import MySQLdb params = dict( host = "...", db = "...", user = "...", passwd = "..." ) while True: conn = MySQLdb.connect(**params) # forget conn.close() !!!
In _mysql.c/_mysql_ConnectionObject_dealloc, _mysql_ConnectionObject_clear() is not called, so it seems that self->converter will not be released.
_mysql_ConnectionObject_clear()
self->converter
It seems to be a side effect of commit below: 21a91a2#diff-b86fdc88461d69279e84018bca8ea267
I think that calling close() explicitly is the best way, but there is room for consideration:
with MySQLdb.connect() as cursor:
__exit__()
The text was updated successfully, but these errors were encountered:
Nice catch.
Connection object can be created as context manager (like with MySQLdb.connect() as cursor:), but close() is not called in exit()
I can't implement it for now, for backward compatibility.
close() is not found in the document
documented here. I don't have motivation to write poor copy of PEP 249 in mysqlclient-python own document.
Sorry, something went wrong.
Thank you for your quick response.
Understood.
I think so too. I will see PEP 249 spec from now on.
Successfully merging a pull request may close this issue.
Connection
object without callingclose()
explicitly will cause memory leak.How to reproduce
Cause?
In _mysql.c/_mysql_ConnectionObject_dealloc,
_mysql_ConnectionObject_clear()
is not called, so it seems thatself->converter
will not be released.It seems to be a side effect of commit below:
21a91a2#diff-b86fdc88461d69279e84018bca8ea267
Discussion
I think that calling
close()
explicitly is the best way, but there is room for consideration:Connection
object can be created as context manager (likewith MySQLdb.connect() as cursor:
), butclose()
is not called in__exit__()
close()
is not found in the documentThe text was updated successfully, but these errors were encountered: