Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Memory allocation


    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!

  2. #2
    Administrator jayd512's Avatar
    Join Date
    Feb 2008
    Google- linux kernel memory allocation

    The top hit looks like a good place to start.

    New users, read this first.
    New Member FAQ
    Registered Linux User #463940
    I do not respond to private messages asking for Linux help. Please keep it on the public boards.

  3. #3
    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.

  4. $spacer_open
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    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.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts