google-code-export / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
1 stars 0 forks source link

memory leak in v2.1.11 when using charset utf8 #223

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
pyodbc v2.1.11
python 2.6.5 32-bit
windows 7

The following simple script leaks memory:

import pyodbc
import gc
import config

while True:
    gc.collect()
    conn = pyodbc.connect(config.connection_string, autocommit=True, charset="utf8")
    conn.close()

Without charset="utf8" it doesn't leak.

Original issue reported on code.google.com by roman.ba...@gmail.com on 7 Nov 2011 at 10:12

GoogleCodeExporter commented 9 years ago
This seems to be fixed as of 3.0.2-beta02.  Can you retest with that version?

Version 3.0.1 crashes due to the charset keyword, so beta02 will be required.

Also, so we can test the same way, how were you measuring the leak?  I ran the 
loop 200,000 times and watched the Private Bytes.  They initially moved up but 
then hovered in the same area and actually came back down to the original size 
at ~20K loops.  Given there is the entire ODBC library plus the driver, some 
initial variability would be expected.

Original comment by mkleehammer on 18 Dec 2011 at 6:45

GoogleCodeExporter commented 9 years ago

Original comment by mkleehammer on 18 Dec 2011 at 7:03

GoogleCodeExporter commented 9 years ago
I am seeing this leak even without the utf8.  Here is how I am monitoring 
memory while the above script is running in another window (Linux):

[nz@NZ80851-H1 scripts]$ while [ true ]; do ps aux --sort -rss | grep python | 
grep -v "grep" | head -n 6; sleep 5; done
nz        4149 53.6  0.2 171684 59000 pts/4    R+   08:29   0:01 python 
./test.py
nz        4149 55.1  0.6 265704 152900 pts/4   S+   08:29   0:04 python 
./test.py
nz        4149 55.5  1.0 360544 247804 pts/4   S+   08:29   0:07 python 
./test.py
nz        4149 55.6  1.3 456800 344056 pts/4   R+   08:29   0:10 python 
./test.py
nz        4149 55.8  1.7 553360 440656 pts/4   S+   08:29   0:12 python 
./test.py
nz        4149 55.8  2.1 650544 537800 pts/4   S+   08:29   0:15 python 
./test.py
nz        4149 55.9  2.5 743656 630972 pts/4   R+   08:29   0:18 python 
./test.py
nz        4149 56.0  2.9 838016 725276 pts/4   S+   08:29   0:21 python 
./test.py
nz        4149 56.1  3.3 932020 819276 pts/4   S+   08:29   0:24 python 
./test.py
nz        4149 56.1  3.7 1027056 914312 pts/4  R+   08:29   0:26 python 
./test.py
nz        4149 56.2  4.0 1123128 1010448 pts/4 S+   08:29   0:29 python 
./test.py
nz        4149 56.2  4.4 1216160 1103544 pts/4 R+   08:29   0:32 python 
./test.py
nz        4149 56.3  4.8 1308412 1195668 pts/4 R+   08:29   0:35 python 
./test.py
nz        4149 56.3  5.2 1401420 1288740 pts/4 R+   08:29   0:38 python 
./test.py

Original comment by larry.j....@gmail.com on 9 Feb 2012 at 1:31

GoogleCodeExporter commented 9 years ago
I should also mention that I am not 3.0.2 yet, will try today.

Original comment by larry.j....@gmail.com on 9 Feb 2012 at 1:31