This project is archived and is in readonly mode.
Memory not released immediately with named cursors
-
flox
- 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
- Assigned user cleared.
-
flox
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
So it's no link in psycopg, just the way the python gc works, right?
-
flox
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
- Title changed from Memory leak with named cursors to Memory not released immediately with named cursors
