Re: Leak repairs

Поиск
Список
Период
Сортировка
От Anoop Kumar
Тема Re: Leak repairs
Дата
Msg-id 02767D4600E59A4487233B23AEF5C5991F174F@blrmail1.aus.pervasive.com
обсуждение исходный текст
Ответ на Leak repairs  ("Dave Page" <dpage@vale-housing.co.uk>)
Список pgsql-odbc
Hi Dave,

I will certainly look into it today. Thanks for the exhaustive checking
of the code!

Regards

Anoop

-----Original Message-----
From: pgsql-odbc-owner@postgresql.org
[mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Dave Page
Sent: Friday, July 15, 2005 7:06 PM
To: pgsql-odbc@postgresql.org
Cc: Anoop Kumar
Subject: [ODBC] Leak repairs

Hi Anoop,

I've spend a while (too long really!) tracking down the memory leaks
we've been seeing in the libpq driver. The code below is enough to see
the problems I've observed using perfmon monitoring the process's
private bytes value.

The attached patch fixes 2 leaks, each of which noticably reduce the
angle of the perfmon trace, however it's not quite flat yet, and my eyes
have gone blurry from looking! It seems to be leaking about 1Kb/per
SQLExecute/SQLFreeStmt (it was 4Kb when I started). It also removes an
unnecessary call to PQgetisnull that I noticed.

I haven't applied any of this to CVS - I'll leave that to you if you're
happy with it.

#include <windows.h>
#include <sqlext.h>
#include <stdio.h>

int main(void)
{
    HENV        hEnv = NULL;
    HDBC        hDBC = NULL;
    HSTMT       hStmt = NULL;
    UCHAR       szDSN[SQL_MAX_DSN_LENGTH] = "psqlodbc-libpq";
    UCHAR       szUID[64] = "postgres";
    UCHAR*      szPasswd = NULL;
    UCHAR       szSqlStr[] = "SELECT 1";
    RETCODE     retcode;
    long        loop = 0;

    SQLAllocEnv (&hEnv);
    SQLAllocConnect (hEnv, &hDBC);
    retcode = SQLConnect (hDBC, szDSN, SQL_NTS, szUID, SQL_NTS,
szPasswd, SQL_NTS);

    if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
    {
        while(loop < 100000)
        {
            retcode = SQLAllocStmt (hDBC, &hStmt);
            retcode = SQLPrepare (hStmt, szSqlStr, sizeof (szSqlStr));
            retcode = SQLExecute (hStmt);
            SQLFreeStmt (hStmt, SQL_DROP);
            loop++;
        }
        SQLDisconnect (hDBC);
    }

    SQLFreeConnect (hDBC);
    SQLFreeEnv (hEnv);

    return 0;
}

Regards, Dave.

В списке pgsql-odbc по дате отправления:

Предыдущее
От: lothar.behrens@lollisoft.de
Дата:
Сообщение: Best way of retrieving tablename from a query ?
Следующее
От: "Joel Fradkin"
Дата:
Сообщение: bad day for Unicode