From 580b5c2f397fbb2f74c2661cfe53203ed6acead0 Mon Sep 17 00:00:00 2001 From: Michael Paquier Date: Thu, 11 Dec 2025 14:11:25 +0900 Subject: [PATCH] pg_buffercache: Fix memory allocation formula The code over-allocated the memory required for os_page_status, relying on uint64 for its element size instead of an int, hence doubling what was required. This could mean quite a lot of memory if dealing with a lot of NUMA pages. Oversight in ba2a3c2302f1. Author: David Geier Discussion: https://postgr.es/m/ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com Backpatch-through: 18 --- contrib/pg_buffercache/pg_buffercache_pages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/pg_buffercache/pg_buffercache_pages.c b/contrib/pg_buffercache/pg_buffercache_pages.c index 3df04c98959..5a3d78d03d5 100644 --- a/contrib/pg_buffercache/pg_buffercache_pages.c +++ b/contrib/pg_buffercache/pg_buffercache_pages.c @@ -366,7 +366,7 @@ pg_buffercache_numa_pages(PG_FUNCTION_ARGS) /* Used to determine the NUMA node for all OS pages at once */ os_page_ptrs = palloc0(sizeof(void *) * os_page_count); - os_page_status = palloc(sizeof(uint64) * os_page_count); + os_page_status = palloc(sizeof(int) * os_page_count); /* Fill pointers for all the memory pages. */ idx = 0; -- 2.39.5