How to find the size / memory space occupied by a "process",

I was asked to write a c / cpp program to find the size of any process in an interview. can anyone tell me how this can be achieved?

ps- before marking que as duplicate - plz read it carefully: I asked how to find through the c / cpp program not only with the unix / linux shell command

+4
source share
3 answers

You can use getrusage . But keep in mind that it is not implemented on all systems.

Or by reading /proc/[pid]/statm

Otherwise, try one of these (command line options).

+2

++ , , .

Linux, , /proc .

, , , ps, ( , Python script).

, , - , , .

+1

size <executable> 

   text    data     bss     dec     hex filename
1361623    1984    2708 1366315  14d92b <executable>

, , bss

0

Source: https://habr.com/ru/post/1539702/


All Articles