c******n 发帖数: 4965 | 1 recently ran into some questions regarding what java is doing when its
starting virtual space is 2G, while running a no-op program.
then I dug into what happens when malloc() is called.
it looks malloc() has 2 mem management methods: it has its own cache of
memory blocks, using "buddy" algorithm, then for larger block requests, it
just mmaps() an anonymous block , **** essentially delegating the task to
kernel mem management *****
then my question is , what happens to kernel when it tries to allocate a
block? it seems that it is never a problem when you request large blocks
that are bigger than several pages, right? ---- you don't have a problem
with finding continuous memory blocks, since all the pages are mapped by
page tables. kernel mem management is only concerned with managing requests
for small blocks (smaller than 1 page ) ???
thanks lot | l*****o 发帖数: 473 | 2 I am trying to answer your questions. However, it is involved in some
complicated mechanism which I can't explain easily.
what happens to kernel when it tries to allocate a
block?
--If you are asking for a block of physical memory, then kernel will
allocate it from its buddy manager.
it seems that it is never a problem when you request large blocks
that are bigger than several pages, right?
---Sure, kernel can allocate a large block, but maybe less than 1024 pages.
This mechanism may change with different kernel version.
you don't have a problem with finding continuous memory blocks, since all
the pages are mapped by page tables.
---yes, Normally user space program won't need continuous physical memory at
all. Only those related to hardware will need it.
kernel mem management is only concerned with managing requests
for small blocks (smaller than 1 page ) ???
---It depends. Those small blocks are managed by slab allocator. Kernel
surely need to manage those requests larger than 1 page. |
|