mmap 不起作用 'when a large chunk becomes “locked” in between smaller ones' 是什么意思?

What does it mean that mmap doesn't work 'when a large chunk becomes “locked” in between smaller ones'?

我正在阅读 GNU 内存分配器的 GNU C 库文档。 https://www.gnu.org/software/libc/manual/html_node/The-GNU-Allocator.html

在关于使用 mmap 分配大块内存的段落中,它说

The other way of memory allocation is for very large blocks, i.e. much larger than a page. These requests are allocated with mmap (anonymous or via /dev/zero; see Memory-mapped I/O)). This has the great advantage that these chunks are returned to the system immediately when they are freed.

Therefore, it cannot happen that a large chunk becomes “locked” in between smaller ones and even after calling free wastes memory.

据我了解,mmap 似乎是一个函数,我可以在其中将连续内存 space 分配给文件(反之亦然?)。

所以我不明白这部分,内存块即使在较小的内存块之间也不能释放吗?然后我们可以将它用于 mmap?

在实际程序中会是什么情况?

考虑分配大量内存的程序的长运行 逻辑函数。同时逻辑函数是 运行,其他代码位分配非常小的内存块。

稍后,那个 long-运行 函数可能会完成,它分配的大量内存将全部释放。但是程序的其他逻辑函数分配的许多小位仍在占用内存。

您可能会遇到程序从操作系统请求大量内存并且几乎所有内存都是空闲的情况,但是程序的分配器无法将任何内存返回给操作系统,因为每个它从系统分配的块仍然有一小块在使用中。这称为“内存碎片”。