Re: Question about MemoryContexts and functions that returns

Поиск
Список
Период
Сортировка
От Thomas Hallgren
Тема Re: Question about MemoryContexts and functions that returns
Дата
Msg-id 44209009.3060506@tada.se
обсуждение исходный текст
Ответ на Re: Question about MemoryContexts and functions that returns  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Question about MemoryContexts and functions that returns  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Tom Lane wrote:
> Thomas Hallgren <thomas@tada.se> writes:
>   
>> As it turns out, I'm not supposed to allocate the returned tuple in the 
>> caller context.
>>     
>
> Where do you get that from?  plpgsql and plperl both do it that way AFAICS.
>
> Are you testing in an --enable-cassert build?  The memory-clobber
> behavior that that turns on is really essential for finding
> dangling-pointer problems ...
>
>   

I use --enable-cassert. I don't think my problem is a dangling pointer.

I just created a dummy C-function that short circuits the 
java_call_handler. It calls my real java function with the correct 
parameters. When I register this function with language C and use it 
instead of the normal function that calls via the java call handler, 
there's no memory leak. It only leaks memory when I go through the call 
handler. The call handler doesn't execute many lines of code and from 
what I can tell, it doesn't manipulate contexts at all. Nor does it 
allocate anything. Further more, I can prevent the leak by allocating 
the returned tuple in a context of my own and free it on the next call.

Is there a difference in how the executor treat a C function and a 
function using a call handler that can cause this behavior?

Regards,
Thomas Hallgren



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: [GENERAL] A real currency type
Следующее
От: Tom Lane
Дата:
Сообщение: Re: 8.2 planning features