Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 6E42C2658F3 for ; Fri, 30 Dec 2011 00:51:02 -0400 (AST) Received: from mahout.postgresql.org ([98.129.198.123]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RgUQi-0002rg-45 for pgsql-bugs@postgresql.org; Fri, 30 Dec 2011 04:51:01 +0000 Received: from [204.145.120.229] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RgUQT-0002Vk-GT for pgsql-bugs@postgresql.org; Fri, 30 Dec 2011 04:50:43 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1RgUQT-0006v7-6U for pgsql-bugs@postgresql.org; Fri, 30 Dec 2011 04:50:41 +0000 Date: Fri, 30 Dec 2011 04:50:41 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #6366: ECPG connection Memory Leak when using Host Variables To: pgsql-bugs@postgresql.org From: li_gang02@sina.com X-Pg-Spam-Score: -3.2 (---) X-Archive-Number: 201112/253 X-Sequence-Number: 32064 The following bug has been logged on the website: Bug reference: 6366 Logged by: Gang, Li Email address: li_gang02@sina.com PostgreSQL version: 9.1.1 Operating system: openSUSE 11.4 (AMD CPU, x86_64bits) Description: = Hallo, /* ** PostgreSQL bug on ECPG connection when using Host Variables ** ** Reference: ** = http://doxygen.postgresql.org/interfaces_2ecpg_2ecpglib_2misc_8c_source.htm= l#l00512 ** File: ** postgresql-9.1.1/src/interfaces/ecpg/ecpglib/misc.c ** Description: ** Function ECPGset_var() will call calloc() to allocate memory for a new node. ** And all nodes are appended to a static global list named 'static struct var_list'. ** But the list memory is never been freed with free() in any case, and no relative function ** is available for me. After ECPG connection is disconnected, ECPGset_var() resultes ** in memory leak (TotalSize =3D n * sizeof(struct var_list), wher= e n is maxium ** of Host Variables used in a DB Connection). ** ** Bug Fixing: ** A new function should be added, details as folloging ** void ECPGfree_var() ** { ** struct var_list *workPtr =3D ivlist; ** while (NULL !=3D workPtr) ** { ** ivlist =3D (struct var_list *)ivlist->next; ** free(workPtr); ** workPtr =3D ivlist; ** } ** ** ivlist =3D NULL; ** } ** ** Also, above function ECPGfree_var() should be called after all SQL queries, and before ** current ECPG connection is going to be closed. */ Best Regards, Gang, Li