Top "Memory-alignment" questions

Memory alignment means that objects and variables reside at particular offsets in the system's memory.

Compelling examples of custom C++ allocators?

What are some really good reasons to ditch std::allocator in favor of a custom solution? Have you run across …

c++ memory-management std memory-alignment allocator
Purpose of memory alignment

Admittedly I don't get it. Say you have a memory with a memory word of length of 1 byte. Why can't …

memory alignment memory-alignment
Are stack variables aligned by the GCC __attribute__((aligned(x)))?

i have the following code: #include <stdio.h> int main(void) { float a[4] __attribute__((aligned(0x1000))) = {1.0, 2.0, 3.0, 4.0}; printf("%p %…

c gcc memory-alignment callstack
Aligning to cache line and knowing the cache line size

To prevent false sharing, I want to align each element of an array to a cache line. So first I …

c linux caching computer-architecture memory-alignment
what is the meaning of align an the start of a section?

What is the meaning of align an the start of a section? For example: align 4 a: dw 0 How does it …

assembly directive memory-alignment
Memory alignment in C-structs

I'm working on a 32-bit machine, so I suppose that the memory alignment should be 4 bytes. Say I have this …

c++ c memory memory-alignment structure-packing
What is the recommended way to align memory in C++11

I am working on a single producer single consumer ring buffer implementation.I have two requirements: Align a single heap …

c++ c++11 dynamic-memory-allocation memory-alignment
What is meant by "memory is 8 bytes aligned"?

While going through one project, I have seen that the memory data is "8 bytes aligned". Can anyone please explain what …

c memory-management memory-alignment
Memory alignment : how to use alignof / alignas?

I work with shared memory right now. I can't understand alignof and alignas. cppreference is unclear : alignof returns "alignment" but …

c++ c++11 x86-64 memory-alignment
how does malloc understand alignment?

following excerpted from here pw = (widget *)malloc(sizeof(widget)); allocates raw storage. Indeed, the malloc call allocates storage that's big …

c++ c memory-alignment