![]() ![]() ![]() ![]() Tasks: 351 total, 1 running, 350 sleeping, 0 stopped, 0 zombie Tasks: 350 total, 1 running, 349 sleeping, 0 stopped, 0 zombie – which are allocated more or fewer resources as the CPU sees fit: top - 22:55:50 up 4:41, 1 user, load average: 0,82, 2,25, 2,72 As we can see in the terminal, there are multiple chrome processes that run and it makes sense because there really are multiple processes that run – the actual chrome application, the opened tabs, maybe some downloads through the browser downloader, etc. I'm on Mac OSX, so I don't have access to /proc/$(pgrep the-programs-name) as far as I know.For example, if we look at the process with the PID 12408 (google chrome instance in this case), we can see the differences in, for example, %CPU which shows how much of the CPU that particular process is using. I'm not sure if it's going up at the same rate, since its granularity is so low that's why I really want a byte count!) (This number is also vastly different from either VSZ or RSS. This produces output like 15M the-programs-nameĪnd then I have to manually extract the first number and multiply it by 1MB so the above line represents 15'000'000 actual bytes at a ridiculously low granularity. Os.system('top -pid $(pgrep the-programs-name) -stats mem,command -l 1 | grep the-programs-name') (Or maybe this discounts swap, so I should look at VSZ? But that's not right either.) ![]() Myself 8707 3.1 0.1 4399204 23500 s013 S+ 10:19AM 0:03.54 the-programs-name -fooĪnd then I have to manually extract the VSZ column and multiply that number by 1024 because it's actually a page count, not a byte count so the above line represents 4'504'784'896 actual bytes. This produces output like USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND Os.system('ps u -p $(pgrep the-programs-name)') The exact meaning of the byte count doesn't matter, just as long as it goes up in the natural way with each malloc or sbrk or whatever. It needs to be something non-interactive so that I can get it from the Python script, and I would like it to report a count of bytes. Problem is, I don't know any good way to get the process's memory usage. Then I can do some arithmetic to find out roughly how much memory is used by each piece of data added. I'm trying to measure the increase in memory footprint of a program as I add data to it, so I've written a Python script that does basically start_the_program() ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |