我真的只想分配64KB的内存,而不是128KB,然后手动进行对齐 - 太浪费了.Windows上的VirtualAlloc正好提供了这种行为.据说SquirrelFish中的代码几乎可以在每个平台上执行此操作,但我还没有设法找到它.是否有一种节省空间的方法在POSIX中的64KB边界上分配64KB?没错,在Linux?
查看 posix_memalign(3)
概要
Run Code Online (Sandbox Code Playgroud)#include <stdlib.h> int posix_memalign(void **memptr, size_t alignment, size_t size);描述
Run Code Online (Sandbox Code Playgroud)The posix_memalign() function allocates size bytes of memory such that the allocation's base address is an exact multiple of alignment, and returns the allocation in the value pointed to by memptr.
有关更多详细信息,请查看联机帮助页...