Proper procedure for logging in and out multipl e times

Brian Bruns camber at ais.org
Thu Jul 4 09:38:58 EDT 2002



Let me take that back, I ran dmalloc on the thing (btw, I've modified all 
the code in src/tds to include

#ifdef DMALLOC
#include <dmalloc.h>
#endif

). Anyway, I found a free'ing of a NULL pointer in mem.c, but otherwise we 
are clean with the current CVS code.  What i did find is that 
gethostbyname() and friends are doing some allocation (3062 bytes) that 
isn't getting released, but that is libc stuff, not our concern, and that 
number stays the same whether it's 10 iterations or 10,000.

So dave, let me know if you are still having problems and if you are, how 
you are gauging the memory leak.

Brian

Happy July 4th to everyone in the states.  To everyone else, sorry you 
have to work today. ;-)  Four day weekend, woohoo!

On Wed, 3 Jul 2002, Brian Bruns wrote:

> 
> Ok, tds_alloc_login()/tds_free_login() are clean.  
> tds_get_config()/tds_free_config() have a slight mem leak, and there's 
> another one somewhere in tds_connect() I have still to resolve. Doesn't 
> look terribly bad though.
> 
> Brian
> 
> On Wed, 3 Jul 2002, Coleman, Dave wrote:
> 
> > I just downloaded the newest snapshot, and applied the same test to the unit
> > directory and the leak still exists.  My application also exhibits the same
> > behavior.  For what it's worth, it appears that the leak is slightly smaller
> > now than with the snapshot I was using.
> > 
> > > -----Original Message-----
> > > From:	Brian Bruns [SMTP:camber at ais.org]
> > > Sent:	Wednesday, July 03, 2002 12:33 PM
> > > To:	TDS Development Group
> > > Subject:	[freetds] Re: Proper procedure for logging in and out
> > > multiple times
> > > 
> > > I applied a patch with some mem leak cleanups in it yesterday...or the day
> > > before.  Is your snapshot version older than that?
> > > 
> > > Brian
> > > 
> > > > I have an application using the freetds C-API that needs to have a
> > > > non-persistant connection to a MS-SQL 7.0 Server.  I have configured
> > > freetds
> > > > to use TDS v4.2, and I have tried both version 0.53 and the latest
> > > snapshot.
> > > > 
> > > > This application is a manufacturing systems control program and it must
> > > use
> > > > a non-persistant connection, as machine operators can shut power off at
> > > any
> > > > time (no, they really shouldn't, but they do), orphaning open
> > > connections to
> > > > the SQL server.  Using the code examples in the unittest directory, I
> > > > constructed a package with non-persistant behaviour for this purpose.  I
> > > > have been experiencing a memory leak with my application, however; and
> > > after
> > > > careful and thorough debugging traced it back to the tds_login(),
> > > > tds_connect(), tds_free_socket(), tds_free_login() function group.
> > > > 
> > > > I modified t0001.c to log in and out multiple times.
> > > > 
> > > > This is the main() function from my modified unit test.
> > > > 
> > > > int main()
> > > >     {
> > > >     TDSLOGIN *login;
> > > >     TDSSOCKET *tds;
> > > >     int ret;
> > > >     int verbose = 0;
> > > >     int i = 0;
> > > >     while( i++<1000 )
> > > >         {
> > > >         fprintf(stdout, "%s: Testing login, logout\n", __FILE__);
> > > >         ret = try_tds_login(&login, &tds, __FILE__, verbose);
> > > >         if( ret != TDS_SUCCEED )
> > > >             {
> > > >             fprintf(stderr, "try_tds_login() failed\n");
> > > >             return 1;
> > > >             }
> > > > 
> > > >         try_tds_logout(login, tds, verbose);
> > > >         }
> > > >     return 0;
> > > >     }
> > > > 
> > > > Is there some clean-up call that I need to make for this code to be
> > > > re-usable?  The unit test code leaks exactly the same memory as my
> > > > application.  I have verified my own memory operations by commenting out
> > > the
> > > > freetds function calls in my object and running the same loop on my
> > > code,
> > > > new'ing and delet'ing every time.  It doesn't leak.
> > > > 
> > > > Thank you in advance for your help,
> > > > 
> > > > Dave Coleman
> > > > Software Engineer
> > > > TI Automotive - Meriden, CT
> > > > dColeman at us.tiauto.com
> > > 
> > > ---
> > > You are currently subscribed to freetds as: [dColeman at us.tiauto.com]
> > > To unsubscribe, forward this message to
> > > $subst('Email.Unsub')
> > 
> > ---
> > You are currently subscribed to freetds as: [camber at ais.org]
> > To unsubscribe, forward this message to $subst('Email.Unsub')
> > 
> > 
> 
> 
> ---
> You are currently subscribed to freetds as: [camber at ais.org]
> To unsubscribe, forward this message to $subst('Email.Unsub')
> 
> 




More information about the FreeTDS mailing list