pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Vikas Mehta <mehta@roguewave.com>
To: pgsql-bugs@postgresql.org
Subject: BUG #6234: Memory leak from PQexec
Date: Wed, 28 Sep 2011 22:22:12 GMT
Message-ID: <201109282222.p8SMMCsH033290@wwwmaster.postgresql.org> (raw)


The following bug has been logged online:

Bug reference:      6234
Logged by:          Vikas Mehta
Email address:      mehta@roguewave.com
PostgreSQL version: 8.4.8
Operating system:   Windows
Description:        Memory leak from PQexec
Details: 

Purify shows 448 bytes of memory leaks with PQexec:

[W] Summary of all memory leaks... {448 bytes, 11 blocks}
    [W] MLK: Memory leak of 128 bytes from 1 block allocated in
ERR_load_SSL_strings [SSLEAY32.DLL]
    [W] MLK: Memory leak of 128 bytes from 1 block allocated in
PQrequestCancel [LIBPQ.DLL]
    [W] MLK: Memory leak of 128 bytes from 1 block allocated in
ENGINE_load_ubsec [LIBEAY32.DLL]
    [W] MLK: Memory leak of 64 bytes from 8 blocks allocated in
add_error_table [COMERR32.DLL]


Test case:
==========

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <libpq-fe.h>



void createTestTable(PGconn* dbc)
{
    PGresult *res;

    printf("\n\nCreating Test Table.....\n");

    res = PQexec(dbc, "create table mytable (col1 int)");
    if (PQresultStatus(res) == PGRES_NONFATAL_ERROR || PQresultStatus(res)
== PGRES_FATAL_ERROR) {
        printf("!!!!! Failed to create test table.\n");
    }
    PQclear(res);
}


void dropTestTable(PGconn* dbc)
{
    PGresult *res;

    printf("\n\nDropping Test Table.....\n");

    res = PQexec(dbc, "drop table mytable");
    if (PQresultStatus(res) == PGRES_NONFATAL_ERROR || PQresultStatus(res)
== PGRES_FATAL_ERROR) {
        printf("!!!!! Failed to drop test table.\n");
    }
    PQclear(res);
}

int main()
{
    PGconn *dbc;
    
    dbc = PQconnectdb("host = magma.cvo.roguewave.com user = username
password = pwd dbname = db");

    if(dbc == 0 || PQstatus(dbc) == CONNECTION_BAD) {
        printf("!!!!! Failed to establish connection.\n");
    }
    
    createTestTable(dbc);
        
    dropTestTable(dbc);
    
    PQfinish(dbc);

    return 0;
}



view thread (4+ messages)  latest in thread

Message-ID: <201109282222.p8SMMCsH033290@wwwmaster.postgresql.org>
Permalink:  ../201109282222.p8SMMCsH033290@wwwmaster.postgresql.org/
Also on:    postgresql.org/message-id/201109282222.p8SMMCsH033290@wwwmaster.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: mehta@roguewave.com
  Subject: Re: BUG #6234: Memory leak from PQexec
  In-Reply-To: <201109282222.p8SMMCsH033290@wwwmaster.postgresql.org>
  References: <201109282222.p8SMMCsH033290@wwwmaster.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox