> > Possible solutions might be:
> > (1) do a context switching in lo_read/lo_write
>
> I agree with this, but I worry a little bit about memory leakage,
> because anything allocated in GlobalMemoryContext is not going to get
> cleaned up automatically. If lo_read/lo_write call any code that is
> sloppy about pfree'ing everything it palloc's, then you'd have a
> long-term leakage that would eventually make the backend run out of
> memory. But it'd be easy enough to test for that, if you have a test
> app that can run the backend through a lot of LO calls.
Yes, I thought about that too. Maybe we could destroy the
GlobalMemoryContext in lo_close() if no LO descriptor exists any more.
Of course this would not prevent the memory leakage if a user forget
to call lo_close, but it's of the user's responsibility anyway.
---
Tatsuo Ishii