Re: Fix OOM when rendering large geometry arrays

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com>
Cc: pgsql-hackers mailing list <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix OOM when rendering large geometry arrays
Date: 2026-11-25 17:52:50
Message-ID: 1300931.1795629170@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrey Rachitskiy <pl0h0yp1(at)gmail(dot)com> writes:
> Proposed fix:
> Copy only the bytes actually used by the rendered text and free the
> 1024-byte buffer. The point, lseg, box, path, and polygon types are
> rendered via path_encode(). circle_out() builds its own buffer and frees it
> in the same way.

This seems quite myopic. Those are far from the only datatypes whose
output functions are memory-profligate. If we wanted to do something
about this, a temporary context similar to what's being discussed in
the adjacent thread about xmlelement() [1] would be a more plausible
answer.

However, I'm resistant to the idea that we need to do something
about this. It will always be possible to run a backend out of
memory. If that results in a crash for you, the right answer
is to fix your OOM-killer configuration so you get a clean ENOMEM
error instead [2].

regards, tom lane

[1] https://www.postgresql.org/message-id/flat/7581277e-e089-417d-867f-8ffd54b9e4c6%40uni-muenster.de
[2] https://www.postgresql.org/docs/current/kernel-resources.html#LINUX-MEMORY-OVERCOMMIT

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kirill Reshke 2026-11-25 17:58:40 Re: OOM kill in xmlelement() with large arrays
Previous Message Álvaro Herrera 2026-11-25 17:51:56 Re: use indnkeyatts not indnatts in loops that read rd_indcollation