]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Allow repalloc() to give back space when a large chunk is downsized.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 3 Oct 2019 17:56:27 +0000 (13:56 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 3 Oct 2019 17:56:27 +0000 (13:56 -0400)
commit4829576ba44b13504448d05f469af15ffc5793b7
tree514f0c0d1a57315f660df40d7972117ba45292a5
parent3473f81dd2a3491ad61be7d7f2917d2af70c423e
Allow repalloc() to give back space when a large chunk is downsized.

Up to now, if you resized a large (>8K) palloc chunk down to a smaller
size, aset.c made no attempt to return any space to the malloc pool.
That's unpleasant if a really large allocation is resized to a
significantly smaller size.  I think no such cases existed when this
code was designed, and I'm not sure whether they're common even yet,
but an upcoming fix to encoding conversion will certainly create such
cases.  Therefore, fix AllocSetRealloc so that it gives realloc()
a chance to do something with the block.  This doesn't noticeably
increase complexity, we mostly just have to change the order in which
the cases are considered.

Back-patch to all supported branches.

Discussion: https://postgr.es/m/20190816181418.GA898@alvherre.pgsql
Discussion: https://postgr.es/m/3614.1569359690@sss.pgh.pa.us
src/backend/utils/mmgr/aset.c