How do modern operating systems manage the heap memory?
Posted: Fri Oct 11, 2013 11:35 am
I was reading up on pointer to pointers, dynamic memory allocations for User programs, and it got me wondering how the operating system keeps track of heap memory for reservation/reallocation/deallocation. I rummaged through some Linux kernel sources on kernel.org, and I can gather that the OS would use linked list data structures to pool out memory, but that's when some head scratching started.
If all local data within locally defined datums are allocated and placed on the stack, to what extent does the program keep track of the allocated memory?
I mean heap memory is dynamically pulled, and to the best of my knowledge the actual stack/process does not keep any reference to the dynamic bits from the pooled memory reserve, so the OS controls it internally within its memory management, or does the runtime thread instruct the OS on hoe to do this via system calls?
I know this is lame, but this, writing a bootloader in ARM v7, and contemplating structure of high level Java apps has perplexed me somewhat.
Is it the OS that allocates, manages, and pools the dynamic memory upon requests internally programmed to provide for the User program, or does a language runtime have more setup in regards to accomplishing this than the OS does by itself?
Like, is it a specific part of the kernel constantly pooling and reserving the pointed addresses for calling requests to use it dynamically via communication from the kernel code itself, or is it the, say, C runtime implementing linked lists, etc.?
If all local data within locally defined datums are allocated and placed on the stack, to what extent does the program keep track of the allocated memory?
I mean heap memory is dynamically pulled, and to the best of my knowledge the actual stack/process does not keep any reference to the dynamic bits from the pooled memory reserve, so the OS controls it internally within its memory management, or does the runtime thread instruct the OS on hoe to do this via system calls?
I know this is lame, but this, writing a bootloader in ARM v7, and contemplating structure of high level Java apps has perplexed me somewhat.
Is it the OS that allocates, manages, and pools the dynamic memory upon requests internally programmed to provide for the User program, or does a language runtime have more setup in regards to accomplishing this than the OS does by itself?
Like, is it a specific part of the kernel constantly pooling and reserving the pointed addresses for calling requests to use it dynamically via communication from the kernel code itself, or is it the, say, C runtime implementing linked lists, etc.?