X-Original-To: pgsql-odbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3C61A52814 for ; Tue, 19 Jul 2005 07:09:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84467-08 for ; Tue, 19 Jul 2005 10:09:11 +0000 (GMT) Received: from fep06-app.kolumbus.fi (fep06-0.kolumbus.fi [193.229.0.57]) by svr1.postgresql.org (Postfix) with ESMTP id 64F40528FF for ; Tue, 19 Jul 2005 07:09:09 -0300 (ADT) Received: from [192.168.1.102] (really [193.229.230.202]) by fep06-app.kolumbus.fi with ESMTP id <20050719100910.NOVL27997.fep06-app.kolumbus.fi@[192.168.1.102]>; Tue, 19 Jul 2005 13:09:10 +0300 Message-ID: <42DCD14B.70604@kolumbus.fi> Date: Tue, 19 Jul 2005 13:09:15 +0300 From: Marko Ristola User-Agent: Debian Thunderbird 1.0.2 (X11/20050331) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dave Page Cc: Anoop Kumar , pgsql-odbc@postgresql.org Subject: Re: Leak repairs References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.331 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200507/81 X-Sequence-Number: 5547 I experimented almost the hole monday with dmalloc library. So that was not efficient. I wanted to see, wether there is a tool, that can debug the psqlodbc library behind UnixODBC under Linux. I don't have any Windows development environment. I could though install Mingw into Windows XP. So, the dmalloc library is under Debian Linux as a package and easy to install though. Here is, how I did it: test.c: #include test.c linking: gcc needed option -ldmallocth (threaded version). I modified psqlodbclibpq in the following way: PGAPI_AllocEnv() function in environ.c: dmalloc_debug_setup("debug=0x4f4ed03,log=liblogfile"); This activates the memory debugging. liblogfile is the file, where the results go. PGAPI_FreeEnv() in environ.c: dmalloc_shutdown(); // before return of return SQL_SUCCESS Actually this setup crashes within dlclose inside UnixODBC library. But, the debugging information will get written into "liblogfile", because the log will be written inside PGAPI_FreeEnv(). I did compile test.c and psqlodbclibpq with -g and without optimizations to achieve a good debugging environment. This was the code block within an active connect: for (i=0; i<5; i++) { if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLAllocHandle(SQL_HANDLE_STMT,m_conn,&m_stmt))) return 1; if (!CHECK(SQL_HANDLE_STMT,m_stmt,SQLExecDirect(m_stmt,(SQLCHAR*) "SELECT * FROM TEST1 LIMIT 100", SQL_NTS))) return 1; if (!CHECK(SQL_HANDLE_DBC,m_conn,SQLFreeStmt(m_stmt,SQL_DROP))) return 1; } Marko Ristola Dave Page wrote: > > > > >>-----Original Message----- >>From: pgsql-odbc-owner@postgresql.org >>[mailto:pgsql-odbc-owner@postgresql.org] On Behalf Of Marko Ristola >>Sent: 19 July 2005 08:37 >>Cc: Anoop Kumar; pgsql-odbc@postgresql.org >>Subject: Re: [ODBC] Leak repairs >> >> >>Have you seen this one? >> >>1121712844: 17186: not freed: '0x404ef808|s1' (800 bytes) from >>'qresult.c:421' >>1121712844: 17186: not freed: '0x404f0c08|s1' (800 bytes) from >>'qresult.c:421' >>1121712844: 17186: not freed: '0x404fd008|s1' (3200 bytes) from >>'qresult.c:421' >>1121712844: 17186: not freed: '0x404fe008|s1' (3200 bytes) from >>'qresult.c:421' >>1121712844: 17186: not freed: '0x404ff008|s1' (3200 bytes) from >>'qresult.c:421' >>1121712844: 17186: not freed: '0x40500008|s1' (3200 bytes) from >>'qresult.c:421' >>1121712844: 17186: not freed: '0x40501008|s1' (3200 bytes) from >>'qresult.c:421' >> >>Line 421 allocates a buffer into QResultClass.backend_tuples. >> >>backend_tuples will be set into NULL in QR_Destructor() with >>"self->backend_tuples = NULL". I suspect, that the memory leak. >> >> >> > >Nicely spotted :-) > >That would appear to be the last of them (at least for my simple testing >at the moment). I'll commit a patch shortly. > >BTW, I assume you got that output from the VC++ debugger - care to share >how? I spent quite some time trying to persuade it to give me that and >didn't get anywhere :-( > >Regards, Dave. > >---------------------------(end of broadcast)--------------------------- >TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match > >