[unixODBC-support] Memory leak in SQLFetch?

Saunders, Steve ssaunders at docucorp.com
Tue Dec 14 16:40:04 GMT 2004


> 
> 
> I am running UnixODBC v2.2.9 on Fedora Core 2 that should have all of
> the latest patches.  I am using freetds v0.62.4 to connect to MS
> SQLServer 2000.  I do not understand the cursor lib comment.  Forgive
> me, I am new to ODBC.
> -Cameron
> 
> Saunders, Steve wrote:
> 
> >
> >  
> >
> >>Craddock, Richard C wrote:
> >>    
> >>
> >
> >  
> >
> >>>Ladies and Gentlemen:
> >>>
> >>> 
> >>>
> >>>I have a reproducible memory leak with the attached code.  
> There are 
> >>>exactly 20160 elements that should be returned from the 
> query.  After
> 
> >>>running this program there is nearly 3Mb of un-freed memory.  If I 
> >>>comment out the SQLFetch() calls then the memory leak goes 
> away.  I 
> >>>suspect that it may have something to do with how I am 
> using unixODBC
> 
> >>>rather then a memory leak in unixODBC.  But I have stared 
> at the code
> 
> >>>for quite sometime to no avail.  Has anyone had a similar 
> problem?  
> >>>Have I made a mistake somewhere?  I appreciate your time and
> assistance.
> >>>
> >>> 
> >>>
> >>>Regards,
> >>>
> >>>Cameron Craddock
> >>>
> >>>      
> >>>
> >
> >Nick wrote
> >  
> >
> >>From a quick read, it looks ok, but it does depend on the driver as 
> >>well, what driver is this using ?
> >>
> >>When you have these sorts of problems, its often worth just 
> trying the
> 
> >>same thing with another database/driver to see if the leak remains.
> >>    
> >>
> >
> >
> >Mr. Craddock, 
> >
> >What version of unixODBC and OS are you using for this memory leak
> test? 
> >
> >We see a similar memory leak problem with unixODBC v2.2.9 
> regardless of
> DB
> >driver (DB2 or MyODBC/MySQL.   We have only tested this version of
> unixODBC
> >on AIX v5.2.  The same tests on unixODBC v2.2.8 on Linux/RedHat does
> not
> >appear to leak.  
> >
> >-Steve
> >  
> >
> 
> Hmm,
> 
> Is it possible the cursor lib being used, and this is contributing to 
> the problem ?
> 
> -- 
> Nick
> 

I will see what I can do to get you a trace, will probably just take
Cameron's code and use it to build a program against our database.  

I have not set any options related to cursor myself, vanilla unixODBC and
our interface doesn't use cursors, so whatever the default is, forward only
I assume, we would be using.  

The only difference with our application vs. Cameron's test is that we don't
fetch a large number of rows all at once, instead we do a lot of selects and
fetches on a very small database repeatedly in a LoadRunner based load test
for 100-200 concurrent users for an extended period of time (hours) and this
is where we see the leak.  To reproduce our leak I can just change his code
to do lots of interations to DB2 and then to MyODBC. 

Could you tell us to the tracing option you want turned on?  

Interbase we don't have but I can also test against ODBC-ODBC with the trail
since we have several databases available on our network (SQL Server, Oracle
8i/9i/10g, DB2 v8, MySQL), after I try the two we have available on that
server.

Thanks,
Steve



More information about the unixODBC-support mailing list