Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
malloc 分配的内存可能会占用几个页面,这些页面不一定彼此相邻,这是正确的吗?
那是对的。
物理上连续的内存只对 DMA 很重要,您不在乎,因为您不在内核空间中。
它将在虚拟地址空间中是连续的。
是的,在物理上它们不能保证是相邻的,但至少在进程的虚拟地址空间中它们看起来是相邻的。
在用户空间中,您很少需要考虑物理内存和连续页面。
malloc将为您提供在虚拟地址空间上连续的内存。如果您知道虚拟内存是如何工作的,那么您就知道无法保证虚拟页面在物理上是连续的。
malloc