Thread: memory leak in ODBC driver

memory leak in ODBC driver

From
"Scot Loach"
Date:
There is a 16-byte leak for every statement handle that has SQLFetch called on it.
I have tracked this leak down to its source:
SC_Fetch calls extend_getdata_info, which allocates memory for the stmt.getdata_info.
However, this memory is never freed when the statement is deallocated.

This patch seems to fix the problem - however I don't know enough about the internals of the driver to really
understandif this is the correct or safe fix. 
Can one of the developers help me out here?

--- statement.c.old     2004-11-27 13:07:57.000000000 -0500
+++ statement.c 2004-11-27 13:09:37.000000000 -0500
@@ -354,6 +354,8 @@
        if (self->callbacks)
                free(self->callbacks);

+        GDATA_unbind_cols(SC_get_GDTI(self), TRUE);
+
        DELETE_STMT_CS(self);
        free(self);

Re: memory leak in ODBC driver

From
"Dave Page"
Date:

> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Scot Loach
> Sent: 27 November 2004 18:11
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] memory leak in ODBC driver
>
> There is a 16-byte leak for every statement handle that has
> SQLFetch called on it.
> I have tracked this leak down to its source:
> SC_Fetch calls extend_getdata_info, which allocates memory
> for the stmt.getdata_info.
> However, this memory is never freed when the statement is deallocated.
>
> This patch seems to fix the problem - however I don't know
> enough about the internals of the driver to really understand
> if this is the correct or safe fix.
> Can one of the developers help me out here?

It certainly *looks* OK to me, but I share the same concerns as you
(I've never really got that far inside the driver before). Anyone else
care to comment?

Regards, Dave.

Re: memory leak in ODBC driver

From
"Scot Loach"
Date:
I've done some more code inspection and I think my fix is ok.

I'll make the change to my code base and I'll let you know if I have any problems with it.

I've submitted bug #1067 for this.

scot.


-----Original Message-----
From:    Dave Page [mailto:dpage@vale-housing.co.uk]
Sent:    Sat 11/27/2004 6:19 PM
To:    Scot Loach; pgsql-odbc@postgresql.org
Cc:
Subject:    RE: [ODBC] memory leak in ODBC driver


> -----Original Message-----
> From: pgsql-odbc-owner@postgresql.org
> [mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Scot Loach
> Sent: 27 November 2004 18:11
> To: pgsql-odbc@postgresql.org
> Subject: [ODBC] memory leak in ODBC driver
>
> There is a 16-byte leak for every statement handle that has
> SQLFetch called on it.
> I have tracked this leak down to its source:
> SC_Fetch calls extend_getdata_info, which allocates memory
> for the stmt.getdata_info.
> However, this memory is never freed when the statement is deallocated.
>
> This patch seems to fix the problem - however I don't know
> enough about the internals of the driver to really understand
> if this is the correct or safe fix.
> Can one of the developers help me out here?

It certainly *looks* OK to me, but I share the same concerns as you
(I've never really got that far inside the driver before). Anyone else
care to comment?

Regards, Dave.



Re: memory leak in ODBC driver

From
"Dave Page"
Date:

> -----Original Message-----
> From: Scot Loach [mailto:sloach@sandvine.com]
> Sent: 30 November 2004 02:31
> To: Dave Page; pgsql-odbc@postgresql.org
> Subject: RE: [ODBC] memory leak in ODBC driver
>
> I've done some more code inspection and I think my fix is ok.
>
> I'll make the change to my code base and I'll let you know if
> I have any problems with it.
>
> I've submitted bug #1067 for this.

OK, thanks. Let me knoiw when you're happy with your testing and I'll
commit the patch given the lack of other opinions!!

Regards, Dave

Re: memory leak in ODBC driver

From
Bruce Momjian
Date:
Dave Page wrote:
>
>
> > -----Original Message-----
> > From: Scot Loach [mailto:sloach@sandvine.com]
> > Sent: 30 November 2004 02:31
> > To: Dave Page; pgsql-odbc@postgresql.org
> > Subject: RE: [ODBC] memory leak in ODBC driver
> >
> > I've done some more code inspection and I think my fix is ok.
> >
> > I'll make the change to my code base and I'll let you know if
> > I have any problems with it.
> >
> > I've submitted bug #1067 for this.
>
> OK, thanks. Let me knoiw when you're happy with your testing and I'll
> commit the patch given the lack of other opinions!!

Scot, is this ready to be applied to ODBC?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Re: memory leak in ODBC driver

From
"Scot Loach"
Date:
Sure, we can apply it, I haven't had any problems with it.

-----Original Message-----
From: pgsql-odbc-owner@postgresql.org
[mailto:pgsql-odbc-owner@postgresql.org]On Behalf Of Bruce Momjian
Sent: Monday, December 20, 2004 8:26 PM
To: Dave Page
Cc: Scot Loach; pgsql-odbc@postgresql.org
Subject: Re: [ODBC] memory leak in ODBC driver


Dave Page wrote:
>
>
> > -----Original Message-----
> > From: Scot Loach [mailto:sloach@sandvine.com]
> > Sent: 30 November 2004 02:31
> > To: Dave Page; pgsql-odbc@postgresql.org
> > Subject: RE: [ODBC] memory leak in ODBC driver
> >
> > I've done some more code inspection and I think my fix is ok.
> >
> > I'll make the change to my code base and I'll let you know if
> > I have any problems with it.
> >
> > I've submitted bug #1067 for this.
>
> OK, thanks. Let me knoiw when you're happy with your testing and I'll
> commit the patch given the lack of other opinions!!

Scot, is this ready to be applied to ODBC?

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Re: memory leak in ODBC driver

From
"Dave Page"
Date:

> -----Original Message-----
> From: Scot Loach [mailto:sloach@sandvine.com]
> Sent: 21 December 2004 15:00
> To: Bruce Momjian; Dave Page
> Cc: pgsql-odbc@postgresql.org
> Subject: RE: [ODBC] memory leak in ODBC driver
>
> Sure, we can apply it, I haven't had any problems with it.
>

Thanks, patch applied.

Regards, Dave.