Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide module-level functions to calculate total system used physical/virtual memory #44

Closed
giampaolo opened this issue May 23, 2014 · 15 comments

Comments

@giampaolo
Copy link
Owner

From jlo...@gmail.com on March 25, 2009 15:49:12

psutil module should have module-level functions to tell total used
physical/virtual memory in bytes and as a percentage of total available.

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

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 25, 2009 07:51:14

Blocked on Issue #43

Blockedon: 43

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 25, 2009 08:13:54

Labels: -Milestone-0.2.0 Milestone-0.1.2

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 25, 2009 19:44:01

Implemented on Linux as r322 .
We're now using the following naming convention:

TOTAL_MEM
used_mem()
total_virtmem()
used_virtmem()

Status: Started

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 25, 2009 19:44:52

Labels: -Progress-0in4 Progress-1in4

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 26, 2009 09:17:42

Implemented on Windows as r324 .

Labels: -Progress-1in4 Progress-2in4

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 29, 2009 10:23:55

I suggest we implement this as the following functions, since it's trivial to
determine both used and avail based on one or the other and the total value. 

total_phymem() (with a constant TOTAL_PHYMEM)
total_virtmem()
used_mem()
avail_mem()
used_virtmem()
avail_virtmem()

Implemented avail_mem/used_mem in FreeBSD as r327 and updated Linux code to use
TOTAL_PHYMEM constant as with other modules, instead of TOTAL_MEM. Still need to
implement avail_virtmem() and used_virtmem() on FreeBSD.

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 29, 2009 10:55:55

Implemented used_mem() and avail_mem() for OS X in r329

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 29, 2009 11:13:53

Determining the used memory is quite easy for the user. It consists in just doing:

> used_mem = tot_mem() - avail_mem()

For this reason I don't think that providing a function for doing that is 
worthwhile, imo.

It's like the current get_process_list() function which consists in nothing but a
"return list(process_iter())" instruction.

I usually tend to be minimalistic in such kind of situations.

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 30, 2009 07:05:42

We're providing a convenience library, so it makes sense to me to provide things
which are likely to be common. I prefer having both available since they're both
likely to be frequently used and it's arbitrary to decide "we provide available
memory, it's up to you to calculate free memory" or vice versa. There's no logical
reason to single out either specific one, so I would prefer not forcing us to make a
choice unnecessarily. Minimalism is generally desirable but we're talking about two
lines of Python code here, I think we can spare it.

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 30, 2009 08:06:09

I'd recommend to rename used_mem() and avail_mem() to used_phymem() and
avail_phymem() for consistency with other function names.

@giampaolo
Copy link
Owner Author

From jlo...@gmail.com on March 30, 2009 11:42:38

I went with avail_mem() and used_mem() just because they're shorter to type, I
figured that was less annoying than avail_phymem() and used_phymem() since the
*virtmem() functions are already separate. Either one is fine but if you rename it
give me a heads up and make sure you rename it in *all* of the files where it's
referenced as well as in _psutil.py __all__ list

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on March 30, 2009 17:10:05

Renamed as r332 .

@giampaolo
Copy link
Owner Author

From billiej...@gmail.com on April 07, 2009 08:51:04

This should be now fixed/implemented on all platforms

Status: Fixed
Labels: -Progress-2in4

@giampaolo
Copy link
Owner Author

From g.rodola on June 09, 2011 15:33:50

Labels: -OpSys-All

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 03:48:11

Updated csets after the SVN -> Mercurial migration: r322 == revision 
1ce59580ce9c r324 == revision e1deef5a07e2 r327 == revision 48c26cd94679 r329 == revision 951dcf2261ee r332 == revision 4db855a26077

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant