Re: realloc overhead (was Multiple sorts in a query) - Mailing list pgsql-hackers

From pg@thetdh.com
Subject Re: realloc overhead (was Multiple sorts in a query)
Date
Msg-id W257492060821931242827453@webmail36
Whole thread Raw
List pgsql-hackers
>>> So at least transiently we use 3x the size of the actual array.
>> I was conjecturing, prior to investigation. Are you saying you know this/have seen this already?
> Well I'm just saying if you realloc a x kilobyte block into a 2x block and the allocator can't expand it and has to copy then it seems inevitable.
FYI the malloc()/realloc()/free() on FC4 causes memory fragmentation, and thus a long-term growth in process memory, under some circumstances. ?This, together with the power-of-two allocations in aset.c not accounting for malloc() overhead (not that they could), implies that memory contexts can cause fragmentation, more slowly, too.
Reallocations of smallish blocks from memory contexts tend to use memory already withheld from the OS; a transient increase in memory usage is possible, but unlikely to matter. ?Perhaps something should be done about larger blocks.
David Hudson

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Compiler warning
Next
From: Tobias Zahn
Date:
Subject: Re: GEQO: ERX