This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
allocating aligned memory efficiently
- From: Joel Dice <joel dot dice at gmail dot com>
- To: libc-help at sourceware dot org
- Date: Fri, 19 Feb 2010 17:34:50 -0700 (MST)
- Subject: allocating aligned memory efficiently
Hi all,
I have a problem which involves allocating memory in chunks, each of a
size which is a multiple of 64K and each aligned to an address divisible
by 64K. I'd like to make these allocations as memory-efficient as
possible, minimizing fragmentation and heap management overhead, and I'd
like to free each one back to the OS promptly when it's no longer needed.
The posix_memalign(3) and free(3) functions seem to have the semantics I
want. Is this pair the most efficient option for my problem, or would I
be better off using mmap(2) or some other mechanism?
Thanks.