Quote:
Originally Posted by vicky007aggrwal
when a new process started in linux how does the memory allocation done for that.
Does that process given Virtual memory & corresponding RAM page for the first time itself or RAM is only allocated if that process need to write anything..?
|
I don't really understand what you are asking. But, it seems like you are partially understanding something about process creation via fork.
When a process is created via fork, almost all of its virtual address space is identical with its parent's virtual address space. Much of that address space has its low level mapping flagged as "copy on write" so than any page that is written by either the parent or child process is duplicated before the write actually proceeds.
Quote:
Second query is what does Resident & Virtual space mean (top command output below)
|
Virtual is the total mapped address space in the process and Resident is the total of those mappings that at the moment point to ram.
Quote:
if i need to see how much memory is used by a process do i need to check the Virtual or RES column value
|
Depends what you mean by "memory" and also depends on what you mean by "used by a process". The reality is too complicated for any simple measure to be correct.
If by "memory" you mean physical ram, then the RES column is usually a good approximation of the value you want.