This project is archived and is in readonly mode.
Memory not released immediately with named cursors
Reported by Psycopg website | August 10th, 2012 @ 11:18 PM
Submitted by: flox
When fetching a named cursor with large records > 16340 bytes, the memory is not released.
Comments and changes to this ticket
-
flox August 10th, 2012 @ 11:24 PM
- Assigned user set to Daniele Varrazzo
This is the test file attached.
And the output:
$ python testmem.py psycopg2 version 2.4.5 (dt dec pq3 ext)
Record size: 1024 B; Memory used: 8.8 MB
Record size: 16339 B; Memory used: 9.0 MB
Record size: 16340 B; Memory used: 205.3 MB
$ -
flox August 10th, 2012 @ 11:25 PM
- no changes were found...
-
flox August 10th, 2012 @ 11:26 PM
- Assigned user cleared.
-
flox August 10th, 2012 @ 11:57 PM
I changed the test_fetch() function to release the memory.
For some reason, "del big_var" is not enough. A "gc.collect()" call is required.def test_fetch(cursor): big_var = range(1 << 23) del big_var gc.collect() cursor.fetchone()
$ python --version Python 2.6.6
$ python testmem.py psycopg2 version 2.4.5 (dt dec pq3 ext)
Record size: 1024 B; Memory used: 8.8 MB
Record size: 16339 B; Memory used: 8.8 MB
Record size: 16340 B; Memory used: 8.8 MB
$ -
Daniele Varrazzo August 14th, 2012 @ 09:18 PM
So it's no link in psycopg, just the way the python gc works, right?
-
flox August 18th, 2012 @ 08:48 AM
I am running this on Debian Squeeze.
It's possibly related to the way the memory is allocated then released.I don't have other test case than the "testmem.py" above.
Could be closed, since I managed to deal with named cursors without any other memory issue. -
flox August 18th, 2012 @ 08:49 AM
- Title changed from Memory leak with named cursors to Memory not released immediately with named cursors
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
<b>WARNING:</b> the informations in this tracker are archived. Please submit new tickets or comments to <a href="https://github.com/psycopg/psycopg2/issues">the new tracker</a>.
<br/>
Psycopg is the most used PostgreSQL adapter for the Python programming language. At the core it fully implements the Python DB API 2.0 specifications. Several extensions allow access to many of the features offered by PostgreSQL.