Skip to Content.
Sympa Menu

freetds - Re: [freetds] Help me. About dbproc's memory leak

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "ldai" <ldai AT accunettech.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>, FreeTDS Development Group <freetds AT lists.ibiblio.org>, FreeTDS Development Group <freetds AT lists.ibiblio.org>, FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Help me. About dbproc's memory leak
  • Date: Fri, 27 Aug 2004 17:48:30 +0800

On Fri, 27 Aug 2004 16:48:07 +0800, ldai wrote
> On Fri, 27 Aug 2004 15:52:41 +0800, ldai wrote
> > Hi,everybody:
> > My test env is freetds-0.62.4+dblib+c+sqlserver+linux 9.
> > When I traced problem about core dump, I found a memory leak.
> > I am just to do connection and relase action in our test code.
> > When I can't success in connecting database, the (DBPROCESS *)dbproc
> > return NULL. I can't use dbclose to clear this structure. If you do
> > dbclose(dbproc),you will get a error :Segmentation fault (core
> > dumped). When I use top command to check memory, I found the memory
> > leak very fast. Could you tell me how to close dbproc when it is NULL?
> > Or give me some advices.
> > Thank you very much.
> > ldai
> > 27,Aug,2004
> > _______________________________________________
> > FreeTDS mailing list
> > FreeTDS AT lists.ibiblio.org
> > http://lists.ibiblio.org/mailman/listinfo/freetds
>
> This is report which is created by dmalloc tools:
> 1093594930: 201: Dmalloc version '5.3.0' from 'http://dmalloc.com/'
> 1093594930: 201: flags = 0x4f4e503, logfile '/tmp/leon_log.txt'
> 1093594930: 201: interval = 100, addr = 0, seen # = 0, limit = 0
> 1093594930: 201: starting time = 1093594930
> 1093594930: 201: process pid = 6747
> 1093595730: 1150101: total-size count source
> 1093595730: 1150101: 15840000 10000 ra=0x8050e7b
> 1093595730: 1150101: 2480000 10000 ra=0x8050f78
> 1093595730: 1150101: 720000 60000 ra=0x8050d00
> 1093595730: 1150101: 70000 60000 ra=0x8050d27
> 1093595730: 1150101: 2317 4 ra=0x40009473
> 1093595730: 1150101: 688 18 ra=0x420ef422
> 1093595730: 1150101: 544 4 ra=0x4000d036
> 1093595730: 1150101: 242 15 ra=0x420ef984
> 1093595730: 1150101: 124 1 ra=0x42097c78
> 1093595730: 1150101: 92 4 ra=0x4000968e
> 1093595730: 1150101: 92 3 ra=0x4000b246
> 1093595730: 1150101: 64 3 ra=0x40004aeb
> 1093595730: 1150101: 64 4 ra=0x420dc3cc
> 1093595730: 1150101: 52 1 ra=0x4201e1ea
> 1093595730: 1150101: 49 4 ra=0x420968fa
> 1093595730: 1150101: 28 1 ra=0x40072f4c
> 1093595730: 1150101: 28 1 ra=0x40004869
> 1093595730: 1150101: 24 2 ra=0x420efa5d
> 1093595730: 1150101: 24 3 ra=0x420ef06c
> 1093595730: 1150101: 20 1 ra=0x4000b158
> 1093595730: 1150101: 15 1 ra=0x4207a1a0
> 1093595730: 1150101: 8 1 ra=0x420ef27e
> 1093595730: 1150101: 19114475 140071 Total of 22
> 1093595730: 1150101: ending time = 1093595730, elapsed since start =
> 0:13:20
>
> [root@nipsvr4 ms_infc_freetds]# gdb ms_sql
> GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
> Copyright 2003 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and
> you are welcome to change it and/or distribute copies of it under
> certain conditions. Type "show copying" to see the conditions. There
> is absolutely no warranty for GDB. Type "show warranty" for
> details. This GDB was configured as "i386-redhat-linux-gnu"...
> (gdb) x 0x8050e7b 0x8050e7b <init_dboptions+19>: 0x8510c483
> (gdb) x 0x8050f78 0x8050f78 <tdsdbopen+24>: 0x8510c483
> (gdb) x 0x8050d00 0x8050d00 <dbstring_concat+40>: 0x8510c483
> (gdb) x 0x8050d27 0x8050d27 <dbstring_concat+79>: 0x8510c483
> (gdb)
>
> Please help me!

I intend to test my code which can't connect database.It is runnung in single-
thread and no pos. I only want to deal with case which the programe can't
access database.
This is my test code:
int MyTestCode()
{
LOGINREC *login;
DBPROCESS *dbproc;
int iFailFlag =0;
int iConnA=0;

dbinit();
login = dblogin();
DBSETLUSER(login, "ldai");
DBSETLPWD(login, "ldai");
DBSETLAPP(login, "Leon-2");

dbproc = dbopen(login, "leon");
if(dbproc==NULL)
{
iConnA=1;
goto f_error;
}else{
iConnA=2;
}

dbclose(dbproc);
dbloginfree(login);
dbexit();
f_error:
if(iFailFlag == 0)
{
if(iConnA == 2)
{
dbclose(dbproc);
}
dbloginfree(login);
dbexit();
}
return -1;
}






Archive powered by MHonArc 2.6.24.

Top of Page