From: | Craig Ringer <craig(at)2ndquadrant(dot)com> |
---|---|
To: | Anderson Carniel <accarniel(at)gmail(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: What is the posix_memalign() equivalent for the PostgreSQL? |
Date: | 2016-09-02 10:24:17 |
Message-ID: | CAMsr+YENaQkaMGp2nTkYkVL04-Amfyaev-RWuRVV+pzCDxia4w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 2 September 2016 at 01:12, Anderson Carniel <accarniel(at)gmail(dot)com> wrote:
> Dear all,
>
> I am developing an extension for the PostgreSQL that write/read some
> external files from the PostgreSQL. In order to write/read, I am using the
> O_DIRECT flag and using the posix_memalign to allocate memory. I would like
> to know if the postgresql internal library provides an equivalent function
> for the posix_memalign since I am getting unexpected errors.
"unexpected errors". Details please?
If you're trying to allocate aligned memory, I believe PostgreSQL
typically uses the TYPEALIGN macros (see c.h) but I'm painfully
clueless in the area, so ... yeah. Don't trust me.
I was a bit surprised not to see a MemoryContextAlloc or palloc
variant that returns memory aligned to a given boundary.
> All my
> allocations are in the TopMemoryContext since I am working with several
> buffers that must be alive while the PostgreSQL Server is activated.
You can't posix_memalign into TopMemoryContext. Such memory is outside
the memory context system, like memory directly malloc()'d.
--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
From | Date | Subject | |
---|---|---|---|
Next Message | Etsuro Fujita | 2016-09-02 10:25:30 | Re: Push down more full joins in postgres_fdw |
Previous Message | Rahila Syed | 2016-09-02 09:55:45 | Re: Surprising behaviour of \set AUTOCOMMIT ON |