Allocating shared memory in Postgres - Mailing list pgsql-general

From Souvik Bhattacherjee
Subject Allocating shared memory in Postgres
Date
Msg-id CAANrPScpwLXFs0FmEXMk5CZRpXUt5q2uL7Ac++oXBujEJ5xzfA@mail.gmail.com
Whole thread Raw
Responses Re: Allocating shared memory in Postgres  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi,

I need to allocate shared memory in Postgres 11.0 outside the initialization phase. In order to achieve this I have done the following:

- increased the amount of shared memory by increasing the value of size in CreateSharedMemoryAndSemaphores (int port) in ipci.c. I have made sure that the amount of memory that I need, say m << M, where M is the amount of additional shared memory that I have allocated.

- during a particular query, where I need to allocate shared memory (which is a function of the sizes of the tables in the query), I invoke ShmemInitStruct() in shmem.c

This seems to work in my case, although I haven't tested it extensively.

My concern here is that when I go through the NOTES in shmem.c, I find the following line:

Fixed-size structures contain things like global variables for a module and should never be allocated after the shared memory initialization phase. 

I'm allocating a shared array data structure through ShmemInitStruct and I'm not sure if the lines above apply to my case, since I'm doing the allocation during a query.

Any help/clarifications in this regard would be appreciated.

Best,
-SB

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: postgres 11 issue?
Next
From: Tom Lane
Date:
Subject: Re: Allocating shared memory in Postgres