Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.support.xappy.memutils Namespace Reference

Functions

def _get_physical_mem_sysconf
def _get_physical_mem_win32
def get_physical_memory

Variables

string __docformat__ = "restructuredtext en"

Function Documentation

Try getting a value for the physical memory using os.sysconf().

Returns None if no value can be obtained - otherwise, returns a value in
bytes.

Definition at line 25 of file memutils.py.

00025 
00026 def _get_physical_mem_sysconf():
00027     """Try getting a value for the physical memory using os.sysconf().
00028 
00029     Returns None if no value can be obtained - otherwise, returns a value in
00030     bytes.
00031 
00032     """
00033     if getattr(os, 'sysconf', None) is None:
00034         return None
00035 
00036     try:
00037         pagesize = os.sysconf('SC_PAGESIZE')
00038     except ValueError:
00039         try:
00040             pagesize = os.sysconf('SC_PAGE_SIZE')
00041         except ValueError:
00042             return None
00043 
00044     try:
00045         pagecount = os.sysconf('SC_PHYS_PAGES')
00046     except ValueError:
00047         return None
00048 
00049     return pagesize * pagecount

Here is the caller graph for this function:

Try getting a value for the physical memory using GlobalMemoryStatus.

This is a windows specific method.  Returns None if no value can be
obtained (eg, not running on windows) - otherwise, returns a value in
bytes.

Definition at line 50 of file memutils.py.

00050 
00051 def _get_physical_mem_win32():
00052     """Try getting a value for the physical memory using GlobalMemoryStatus.
00053 
00054     This is a windows specific method.  Returns None if no value can be
00055     obtained (eg, not running on windows) - otherwise, returns a value in
00056     bytes.
00057 
00058     """
00059     try:
00060         import ctypes
00061         import ctypes.wintypes as wintypes
00062     except ValueError:
00063         return None
00064     
00065     class MEMORYSTATUS(wintypes.Structure):
00066         _fields_ = [
00067             ('dwLength', wintypes.DWORD),
00068             ('dwMemoryLoad', wintypes.DWORD),
00069             ('dwTotalPhys', wintypes.DWORD),
00070             ('dwAvailPhys', wintypes.DWORD),
00071             ('dwTotalPageFile', wintypes.DWORD),
00072             ('dwAvailPageFile', wintypes.DWORD),
00073             ('dwTotalVirtual', wintypes.DWORD),
00074             ('dwAvailVirtual', wintypes.DWORD),
00075         ]
00076 
00077     m = MEMORYSTATUS()
00078     wintypes.windll.kernel32.GlobalMemoryStatus(wintypes.byref(m))
00079     return m.dwTotalPhys

Here is the caller graph for this function:

Get the amount of physical memory in the system, in bytes.

If this can't be obtained, returns None.

Definition at line 80 of file memutils.py.

00080 
00081 def get_physical_memory():
00082     """Get the amount of physical memory in the system, in bytes.
00083 
00084     If this can't be obtained, returns None.
00085 
00086     """
00087     result = _get_physical_mem_sysconf()
00088     if result is not None:
00089         return result
00090     return _get_physical_mem_win32()

Here is the call graph for this function:


Variable Documentation

string MoinMoin.support.xappy.memutils.__docformat__ = "restructuredtext en"

Definition at line 21 of file memutils.py.