Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PostgreSQL 7.2 memory leaks on Rad Hat 7.1

Status
Not open for further replies.

tolian21

Programmer
Aug 8, 2002
1
US
The following program leaks memory, anybody knows why?
void f(void * arg)
{
char * dbName ="xxxxxxx";
char * lanName = "goosexxx";
PGconn * conn = NULL;

conn = PQsetdb( lanName,
NULL,
NULL,
NULL,
dbName
);
if ( PQstatus(conn) == CONNECTION_BAD )
{
if( DebugIndicator )
{
fprintf(stderr,
"Connection to [dbName=%s lanName=%s threadId=%d]"
" failed.\n", dbName, lanName, (int) pthread_self() );
fprintf(stderr, "%s", PQerrorMessage(conn));
}
PQfinish(conn);
conn=NULL;
}
PQfinish(conn);
poll(0,0,100);
pthread_exit(NULL);

}
int main()
{
pthread_t pd;
while(1)
{
pthread_create(&pd, NULL, f, (void *) NULL);
pthread_join(pd, NULL);
}
return 0;
}

/**************************/
This only happens with threads, if I do not use threads and simply call f() in the loop the program does not leak.
Also, if I comment out PostgreSQL stuff from f() and call it through thread, there is no problem!

Looks like there is a problem with Red Hat 7.1 or PostgreSQL!
Anybody knows why?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top