Hmm. How did you run this experiment, exactly? I suspect if you were
using so little memory that either NOTIFY wasn't spinning fast enough
or you were running identical NOTIFYs in one transaction, which get
folded to exactly one entry. For example, running:
DO $$
BEGIN
LOOP
perform pg_notify('queue_classic', random()::text); END LOOP;
END; $$
;
In a backend will result in much faster accrual of memory usage than
you describe (and certainly this approach could be 'improved' to
occupy more memory faster. Note that this loop will never actually
notify any backends because it runs in a transaction and your only
choice will be to cancel it and all its notifies.
Secondly, when it comes to testing the client, we know that psql
drains notifications because it dumps them all to the terminal and is
done with them. What you may have noticed is that it only does so
when one has done some 'stuff' on the database connection, like
"select 1;". In libpq, the completely statementless version of 'check
for some input' is 'consume input', and it is necessary to call this
at least once to ensure the client buffers the notifies to have a
chance to reproduce this behavior.
--
fdr