Some questions puzzling me:
When the kernel allocate physical memory to a process, is there a certain limit of KB/MB or pages the kernel can allocate?
If a program requests a huge amount of memory, does the kernel give the requested amount at a time? Or does it allocates in small pieces(not continuous physically)?
Is it possible that a user program can roll its own physical memory allocator, instead of resorting to kernel?
Thanks in advance!
Google- linux kernel memory allocation
The top hit looks like a good place to start.
Please clarify something for me. When a user program requests some memory in user space, does this request go to the OS kernel? Since only the OS knows which physical locations can be allocated to the process(?), Or can a user process have access to the data structure which stores all the free physical pages directly(then operate on it)? My understanding is no, but still enlighten me please.
My question was: does Linux OS has any limit on the amount of physical memory can be allocated to a user process (in user space) if OS is in this process?
Uh, I am confusing myself.
The malloc/free and related API calls are not system (kernel) calls, though one function they use when necessary, brk(), is. The brk() function, called by malloc() and friends, sets the end of the process data segment. This is virtual memory, and where it is physically mapped to depends entirely on the kernel. Once the process virtual memory space has been allocated/set, then malloc() and free() can physically manipulate it to allocate and delete dynamic memory from that space. The amount of space that brk() asks for is generally in some number of system pages.
As for size limits, that is determined by the process limits, which is determined at runtime by a call to getrlimit(). The system command ulimit can alter this up to system or administrator defined maximum values.