🌐 AI搜索 & 代理 主页
Skip to content

Commit 580b5c2

Browse files
committed
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 ba2a3c2. Author: David Geier <geidav.pg@gmail.com> Discussion: https://postgr.es/m/ad0748d4-3080-436e-b0bc-ac8f86a3466a@gmail.com Backpatch-through: 18
1 parent 5b7bbf1 commit 580b5c2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/pg_buffercache/pg_buffercache_pages.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ pg_buffercache_numa_pages(PG_FUNCTION_ARGS)
366366

367367
/* Used to determine the NUMA node for all OS pages at once */
368368
os_page_ptrs = palloc0(sizeof(void *) * os_page_count);
369-
os_page_status = palloc(sizeof(uint64) * os_page_count);
369+
os_page_status = palloc(sizeof(int) * os_page_count);
370370

371371
/* Fill pointers for all the memory pages. */
372372
idx = 0;

0 commit comments

Comments
 (0)