4 ms·
What's interesting to me is how the memory used for buffering data is accounted for in system statistics. If we want to attribute this memory to a process, then
by yakubin 5y ago
What's interesting to me is how the memory used for buffering data is accounted for in system statistics. If we want to attribute this memory to a process, then attributing it to the writer seems to be the natural option, since they are the ones responsible for using this memory. However, killing the writer after they wrote to the pipe won't free up this memory, because it's buffered. So I guess it could be counted in the Working Set Size of all the processes that have the read end of the pipe[1]? In practice, I think it's counted as "system memory". I'd prefer the Working Set Size approach, since it gives you an indication that to free up this memory you need to kill those processes.
[1]: So for each reader process we would add S/N to its WSS, where S is the size of the buffered data for the pipe, and N is the number of processes holding the read end of the pipe.