Aligned memory management?

后端 未结 7 1868
清歌不尽
清歌不尽 2020-12-13 05:00

I have a few related questions about managing aligned memory blocks. Cross-platform answers would be ideal. However, as I\'m pretty sure a cross-platform solution does not

相关标签:
7条回答
  • 2020-12-13 05:35

    The trickiest requirement is obviously the third one, since any malloc() / realloc() based solution is hostage to realloc() moving the block to a different alignment.

    On Linux, you could use anonymous mappings created with mmap() instead of malloc(). Addresses returned by mmap() are by necessity page-aligned, and the mapping can be extended with mremap().

    0 讨论(0)
提交回复
热议问题