giampaolo / psutil

Cross-platform lib for process and system monitoring in Python
BSD 3-Clause "New" or "Revised" License
10.2k stars 1.38k forks source link

Support for per-process memory bytes/KB utilization #38

Closed giampaolo closed 10 years ago

giampaolo commented 10 years ago

From jlo...@gmail.com on March 12, 2009 17:37:04

psutil should support per-process memory utilization statistics in both raw
(e.g. bytes) numbers and % utilization.

Original issue: http://code.google.com/p/psutil/issues/detail?id=38

giampaolo commented 10 years ago

From billiej...@gmail.com on March 17, 2009 09:19:35

Labels: Progress-0in4

giampaolo commented 10 years ago

From billiej...@gmail.com on March 17, 2009 14:50:01

As for raw bytes information we need to decide what values we want to return.
Since figuring out how memory works on all different platforms is very complex as for
now I think we better return the minimal information possible for simplicity and add
more detailed information in future releases.

Figuring out which information are portable between different platforms is also of
primary importance.

On Linux we can easily retrieve virtual and resident memory, known under ps by the
name of VMS and RSS respectively, but I'm not sure that summing them will give us the
total memory used by the process (for example, this article makes me raise more than
one doubt: 
http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html ).

As for the data type we want our get_memory_info() function to return I think we have
two options:

- returning a tuple, like we did for get_cpu_usage() function
- returning a MemoryInfo class instance similar to ProcessInfo containing memory
values accessible as class attributes

Considering that in future release we might add new memory information, using a
MemoryInfo class would make more sense to avoid breaking backward compatibility.

My2cents

Labels: -OpSys-All

giampaolo commented 10 years ago

From billiej...@gmail.com on March 17, 2009 14:52:03

Cc: yanraber

giampaolo commented 10 years ago

From jlo...@gmail.com on March 20, 2009 11:40:22

We should provide properties for RSS and VMS just like top/ps/taskmgr all do. The
numbers should not be added since in most cases it is desirable to differentiate
between virtual memory size and resident memory size. From what I've seen all
platforms differentiate between the two and it's reasonably straightforward to
retrieve RSS/VMS per-process.

I'm not decided on what the implementation should be but I think it makes sense to
have the interface be simple properties for rss/vms and perhaps mem_util or something
like that for % utilization.
giampaolo commented 10 years ago

From billiej...@gmail.com on March 20, 2009 14:48:35

Percent utilization has been moved into issue 41 .

Summary: Support for per-process memory bytes/KB utilization

giampaolo commented 10 years ago

From billiej...@gmail.com on March 20, 2009 19:04:12

Implemented on OS X, FreeBSD, Windows and Linux as r277 , r278 , r279 and r280 .
Leaving this open as long as test cases are available and working.

Labels: -Progress-0in4 Progress-4in4

giampaolo commented 10 years ago

From billiej...@gmail.com on March 21, 2009 05:39:00

r289 attempts to implement a semi-reliable test case.
giampaolo commented 10 years ago

From g.rodola on March 02, 2013 03:47:24

Updated csets after the SVN -> Mercurial migration: r277 == revision 4ff2f6621026 r289 == revision decb1e50ad3f