From: | Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru> |
---|---|
To: | Dirk Rudolph <dirk(dot)rudolph(at)netcentric(dot)biz>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Leaking memory in text_overlay function |
Date: | 2016-08-04 07:56:41 |
Message-ID: | 18dc117a-f925-dfc9-0546-f9ac83573105@postgrespro.ru |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I found this thread on the open CF. As I see, the discussion is ended
with decision to reject patch.
I've just changed the status to "Rejected".
02.07.2016 18:11, Dirk Rudolph:
> Well that's good to know. It was just curious that, in my case, I only
> saw this in this particular function.
>
> Anyway. I will consider to handle the memory the same way, if this is
> the recommendation.
>
> Many thanks.
>
> /Closed
>
> On Sat, Jul 2, 2016 at 4:45 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us
> <mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us>> wrote:
>
> Dirk Rudolph <dirk(dot)rudolph(at)netcentric(dot)biz
> <mailto:dirk(dot)rudolph(at)netcentric(dot)biz>> writes:
> > while implementing my own C function, I mentioned that some
> memory is not freed by the text_overlay function in varlena.c
>
> By and large, that's intentional. SQL-called functions normally run
> in short-lived memory contexts, so that any memory they don't
> bother to
> pfree will be cleaned up automatically at the end of the tuple cycle.
> If we did not follow that approach, there would need to be many
> thousands
> more explicit pfree calls than there are today, and the system
> would be
> net slower overall because multiple retail pfree's are slower than a
> MemoryContextReset.
>
> There are places where it's important to avoid leaking memory,
> certainly.
> But I don't think this is one of them, unless you can demonstrate a
> scenario with query-lifespan or worse leakage.
>
> > Particularly I mean the both substrings allocated by
> text_substring (according to the documentation of text_substring
> "The result is always a freshly palloc'd datum.") and one of the
> concatenation results. I’m aware of the MemoryContext being
> deleted in my case but IMHO builtin functions should be memory safe.
>
> That is not the project policy.
>
> regards, tom lane
>
>
>
>
> --
>
> Dirk Rudolph | Senior Software Engineer
>
> Netcentric AG
>
> M: +41 79 642 37 11
> D: +49 174 966 84 34
>
> dirk(dot)rudolph(at)netcentric(dot)biz <mailto:dirk(dot)rudolph(at)netcentric(dot)biz> |
> www.netcentric.biz <http://www.netcentric.biz/>
>
--
Anastasia Lubennikova
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company
From | Date | Subject | |
---|---|---|---|
Next Message | Torsten Zuehlsdorff | 2016-08-04 09:00:25 | Re: Why we lost Uber as a user |
Previous Message | Andres Freund | 2016-08-04 07:52:46 | Re: [RFC] Change the default of update_process_title to off |