maximally misaligned

Bradley C. Kuszmaul kuszmaul at gmail.com
Wed Dec 26 15:50:40 PST 2012


It would be useful if there were a way to configure jemalloc to give
the worst acceptable alignment for every returned object.

I'm currently debugging a program that uses O_DIRECT for file I/O.
This option requires that all pointers passed to read() and write() be
512-byte aligned.  There is an occasional function that uses malloc()
to create a buffer instead of something like memalign().  I'd like it
if the malloc() could be tweaked so that the returned pointer from
malloc(4096) was aligned to be off by, say 16 bytes.  Otherwise there
fact that malloc(4096) seems to return a 512-byte aligned pointer
masks a bug in the program.

I've implemented this misaligned mallocator on top of malloc() for my purposes.

Is this something that might belong in the jemalloc library instead of
in my code?  Maybe it's already there and I don't know about it.
Maybe this is a dumb idea and it really belongs in the application, as
I've done it.

Any thoughts?

-Bradley



More information about the jemalloc-discuss mailing list