#9262 closed (invalid)
Memory leak in django.utils.version.get_svn_revision
Reported by: | Ilya Semenov | Owned by: | nobody |
---|---|---|---|
Component: | Uncategorized | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
django.utils.version.get_svn_revision suffers from a memory leak: it opens a file without closing it. I'm attaching the trivial patch.
Attachments (1)
Change History (5)
by , 16 years ago
Attachment: | 9107.patch added |
---|
comment:1 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 16 years ago
Resolution: | invalid |
---|---|
Status: | closed → reopened |
You can't assume CPython refcounting now that Django runs officially on Jython.
Quote from http://jython.sourceforge.net/docs/differences.html:
Jython has "true" garbage collection whereas CPython uses reference counting. This means that in Jython users don't need to worry about handling circular references as these are guaranteed to be collected properly. On the other hand, users of Jython have no guarantees of when an object will be finalized -- this can cause problems for people who use open("foo", 'r').read() excessively. Both behaviors are acceptable -- and highly unlikely to change.
comment:3 by , 16 years ago
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
"no guarantees of when an object will be finalized" != "object will never be finalized". If we were opening thousands of files and never explicitly closing them, there might be a case for changes (since they might not get auto-collected soon enough), but that's not what's happening, so let it rest.
comment:4 by , 16 years ago
I am the topic starter and I agree with closing the ticket as invalid. I was reported about the memory leak by our team profiling results and didn't check myself if it actually took place (my bad).
Python files are automatically closed when the reference count drops to zero, which happens immediately in this case.
For example: