Re: memory leak in libxml2 - fix

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: memory leak in libxml2 - fix
Date: 2010-11-26 20:12:53
Message-ID: AANLkTinG2Z+giEnO2Kwm_zJobyaqDA_FPHSeqvAhhDNv@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/11/26 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
>> 2010/11/26 Itagaki Takahiro <itagaki(dot)takahiro(at)gmail(dot)com>:
>>> Why did you change doctree and ctxt to global variables?
>>> I'm not sure why /* xmlFreeDoc(doctree); */ is commented out
>>> at the end of pgxml_xpath(), but is it enough to enable the code?
>
>> I am thinking, so you must not to call xmlFreeDoc(doctree) early.
>> Probably xmlXPathCastToXXX reading a doctree.
>
> Those static variables are really ugly, and what's more this patch only
> stops some of the leakage.  Per experimentation, the result object from
> pgxml_xpath has to be freed too, once it's been safely converted to
> whatever the end result type is.  You can see this by watching
>
> select sum(xpath_number('<data>' || generate_series || '</data>','/data')) from
> generate_series(1,500000);
>
> which still shows leakage with the submitted patch.  I cleaned it up
> as per attached, which doesn't show any leakage.

great

thank you very much

regards

Pavel Stehule
>
>                        regards, tom lane
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitriy Igrishin 2010-11-26 20:26:19 Re: Re: [BUGS] BUG #5650: Postgres service showing as stopped when in fact it is running
Previous Message Alvaro Herrera 2010-11-26 20:06:30 Re: improving foreign key locks