|
From: | Thomas Gamper |
Subject: | Re: Alignment issue? |
Date: | Fri, 05 Jul 2013 15:39:15 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130330 Thunderbird/17.0.5 |
Hi!
I think that is caused by the implicit padding caused by the reference counter inside each NSObject. Basically memory is allocated for the reference counter + object size, but the reference counter is located at the start of the allocated memory chunk, so you get a pointer offset by the amount of bytes the reference counter needs. malloc returns a 16 byte aligned address, the first few bytes of the chunk are needed for the reference counter which has the size of an unsigned long, meaning 8 byte on Linux/AMD64, so you end up with a pointer pointing to the memory after the reference counter, which is the 16 byte aligned address + 8 bytes. Cheers, TOM On 2013-07-05 15:09, Laurent Michel wrote: Good morning! |
[Prev in Thread] | Current Thread | [Next in Thread] |