iphone - iPhone 和 Android 上的内存对齐

标签 iphone c++ android c memory

正如我从测试中发现的那样,iPhone 的 malloc 具有 16 字节对齐。但我不确定这是有保证的还是只是巧合。

所以问题是:在 iOS 和 Android(NDK) 上使用 malloc() 时保证的内存对齐是什么?

最佳答案

正如您所发现的,在 iOS 上,当前对齐是 16 个字节。但是,这并不能保证,也不能记录在案。 IE。不要依赖它。

假设它在 iOS 上可用,posix_memalign() 允许分配专门对齐的内存。可能还有其他机制。

Android 不是我的职责。

关于iphone - iPhone 和 Android 上的内存对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5208356/

相关文章:

iphone - 是否可以在 MKAnnotationView 而不是 MKPinAnnotationView 中调用 animatesDrop ?

ios - index 0 beyond bounds for empty array' *** First throw call stack :

c++ - 使用 chrono 测量性能,顺序似乎很重要,尽管它不应该

android - 在 Espresso 测试中禁用自动更正功能

android - 类广播异常 achartengine

android - 为什么 isMultipleAdvertisementSupported() 在 getBluetoothLeAdvertiser 返回对象时返回 false?

iphone - 谁能告诉我为什么 UIImage.ciimage 为空

jquery - 使用 PhoneGap 显示 'back' 按钮

c++ - 有符号整数溢出在 C++ 中仍然是未定义的行为吗?

c++ - 使用 Caffe 运行简单的 C++ 程序