[freetds] memory leak for connect with db-lib
ZIGLIO, Frediano, VF-IT
Frediano.Ziglio at vodafone.com
Thu May 27 06:13:44 EDT 2004
>
> Hi, everybody:
> I user freeTDS 0.61-2 rpm to develop db-lib programe to access MS-
> SQLSREVER from linux enrivement. Now I found that I'm just
> only to connect db
> and to release connection, it will cost about 200k memory and
> don't release
> every time.
> How can i deal with problem?
> Thank very much.
> leon
> 2004-05-27
>
> F.E:
> /**
> getDBLogin.c
> */
> LOGINREC *getDBLogin(char sUserName[60], char sPasswd[60])
> {
> LOGINREC *login;
> /* Initialize DB-Library. */
>
> dbinit();
> login = dblogin();
> DBSETLUSER(login, sUserName);
> DBSETLPWD(login, sPasswd);
> DBSETLAPP(login, "Leon-2");
> return login;
> }
>
> /**
> getDBproc.c
> */
> DBPROCESS *getDBproc(LOGINREC *dbLogin)
> {
> DBPROCESS *retProc;
> retProc = dbopen(dbLogin, NULL);
> return retProc;
> }
>
> /**
> main.c
> */
> #include <stdio.h>
> #include <sybfront.h>
> #include <sybdb.h>
>
> main(argc,argv)
> int argc;
> char *argv[];
> {
> LOGINREC *Ldblogin;
> DBPROCESS *testProc;
> int iRetCode=0;
> char sGetVal[255];
> char sNewDomain[255];
> char sRetMsg[1024];
> char sMsg[1024];
> int i=0;
>
> memset(sNewDomain, 0, sizeof sNewDomain);
> memset(sRetMsg, 0, sizeof sRetMsg);
> memset(sMsg, 0, sizeof sMsg);
> for(i=0; i<1000; i++)
> {
> printf("\n-----loop=[%d]-----\n",i);
> Ldblogin = (LOGINREC *)getDBLogin("test", "test");
> testProc = (DBPROCESS *)getDBproc(Ldblogin);
> dbclose(testProc);
>
> dbloginfree(Ldblogin);
> dbexit();
> }
> }
>
You should call dbinit/dbexit only once.
Try updating. Current release is 0.62.3 (you are using debian, don't
you?)
freddy77
More information about the FreeTDS
mailing list