Leak repairs

Поиск
Список
Период
Сортировка
От Dave Page
Тема Leak repairs
Дата
Msg-id E7F85A1B5FF8D44C8A1AF6885BC9A0E4AC92A3@ratbert.vale-housing.co.uk
обсуждение исходный текст
Список pgsql-odbc
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 по дате отправления:

Предыдущее
От: "Dave Page"
Дата:
Сообщение: Re: Fix for the 'null value' bug
Следующее
От: "Greg Campbell"
Дата:
Сообщение: Re: Has anyone accessed postgresql in linux from VB code