There's only one call of ShmemAlloc() left in the tree outside shmem.c,
in StatsShmemInit(), and that call doesn't look right:
The StatsShmemSize() function takes those allocations into account when
it calculates the size for the "Shared Memory Stats" shmem area, but
ShmemAlloc() doesn't use that reservation, it uses the general-purpose
unreserved shmem that then shows up as "<anonymous>" in
pg_shmem_allocations. The space reserved with ShmemRequestStruct() /
ShmemInitStruct() goes unused.
We should use the memory that we've reserved, per the attached patch.
One consequence of this fix though is that the allocations are now only
MAXALIGNed, while ShmemAlloc() uses CACHELINEALIGN(). Not sure which we
want.
I noticed this while working on the new shmem allocation functions, but
it's a pre-existing bug in stable branches too.
- Heikki