Win32 memory allocation with large alignment

后端 未结 2 778
遥遥无期
遥遥无期 2021-01-13 19:23

I need to allocate large regions of memory (megabytes) with large alignments (also potentially in the megabyte range). The VirtualAlloc family of functions don\'t seem to p

2条回答
  •  臣服心动
    2021-01-13 19:49

    Have a look at the source for _aligned_malloc in the windows/MSVC crt, its very simple to use the same method to align virtual memory, i'd would even go so far as to say, just replace its internal malloc call (same goes for _aligned_free), this allows allocation with only a single system call.

    However, why do you need such massive alignment? Are you trying to abuse address bit patterns for fast memory block slabs?

提交回复
热议问题