"Viatcheslav" <vka@ipcb.net> writes:
> We are aware of additional costs of exceptions yet this one appears to be a
> memory leak.
AFAICT, the only memory consumed per-iteration by your example is the
subtransaction XID that's added to the list of XIDs for eventual commit.
It's not really possible to dispense with storing it.
regards, tom lane