Dirk Rudolph <dirk.rudo...@netcentric.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 -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers